aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j: Logger does not log Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j: Logger does not log" Watch "log4j: Logger does not log" New topic
Author

log4j: Logger does not log

Ole Hornischer
Greenhorn

Joined: Nov 14, 2008
Posts: 27
Hey everyone!
I have a problem with log4j. I am using it in a signed jar file (in order to log on the client pc).
I would like the client to write to a daily rolling file appender, and when starting the client the logfiles are created too, but the logger simply does not log to them. I am suspecting there is sth wrong with my properties file, but i cannot figure out what. any ideas?



In an earlier version (the file looked a bit different) I used the properties files on a local class, just to test it and there the logger logged properly. Could it also be that there is a problem with the jar file?

--Thelonius
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Do you create the logger object via commons logging or via log4j directly?
Is there any other log4j.properties in the client classpath?


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Ole Hornischer
Greenhorn

Joined: Nov 14, 2008
Posts: 27
I create it via log4j. the properties file is located in the signed jar and being loaded from there. That apparently works, because the application does create the log files. It simply does not write to them.

Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Can you try this code to see what will be printed on the Console?

If they both return false, try to add this line to your log4j.properties file:

[ December 07, 2008: Message edited by: Duc Vo ]
Ole Hornischer
Greenhorn

Joined: Nov 14, 2008
Posts: 27
Hi!
I used the TZALogger class to encapsulate the log4j and let it be configured in a central place.
But I now learned about the common-logging library, which apparently does exactly this. So I will try to switch to that and hope my problems will be solved.
(I worked a bit more on that issue on friday and the configuration showed very strange behaviour: When configuring, the target log files where created, but logs in the same class would just not log. Logging from another class (with the same configuration) worked just fine. So I am guessing the error was deeper and am hoping that switching to common-logging will solve the issue(s))
--Thelonius
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Good luck! just to remind that you will need to configure commons logging to use log4j as the implementation logger.
[ December 08, 2008: Message edited by: Duc Vo ]
Ole Hornischer
Greenhorn

Joined: Nov 14, 2008
Posts: 27
commons logging works great, configuration was very easy, once i renamed my properties file to the default log4j.properties.
 
wood burning stoves
 
subject: log4j: Logger does not log