Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j log files

 
Sangeetha Rao
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using log4j in a project where the web server is Tomcat. After the project is executed, the log file contains many DEBUG information apart from those that I have logged. How to prevent such junk debug messages from being logged into my log file.
 
KArol Muszynski
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read about category.priority and logger.level parameters from log4j configuration file. Changing them will help You to prevent unwanted data to be logged.
Also in logger tag, You can filter data to be logged only from Your packages.

helpful link: http://wiki.apache.org/logging-log4j/Log4jXmlFormat

Best Regards,
KArol Muszynski
 
Sangeetha Rao
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That really was a useful link. Thanks a lot. But my problem is this: I am aware of the priority levels. I have given the level for the appender as DEBUG. This means any message logged with any of DEBUG, INFO, WARN, ERROR, FATAL levels will go into this log file. But the problem here is that the log file contains certain DEBUG level messages that I havent logged anywhere in my application. I guess they are server logs coming into my log file. How can I filter them ?
 
Bernhard B�hm
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe a rootCategory would help you, where you define:
-------------
log4j.rootCategory=INFO, FILE
-------------
where "FILE" must then redirect to your log file settings.

So I guess all logging information with category INFO or higher will be logged, and, if you define a special category for your logging messages, you can also DEBUG your own messages...

Didn't try it out, hope it works!
 
KArol Muszynski
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by S.Sangeetha Rao:
I guess they are server logs coming into my log file. How can I filter them ?


For example You can write Your own filter:




Best Regards,
KArol Muszynski
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic