• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j: Logger does not log

 
Ole Hornischer
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you create the logger object via commons logging or via log4j directly?
Is there any other log4j.properties in the client classpath?
 
Ole Hornischer
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
commons logging works great, configuration was very easy, once i renamed my properties file to the default log4j.properties.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic