Re: How to filter the unnecessary log messages
[Not pasting the big log file] You need to use a log4j.xml in the classpath. The format/how to of the log4j.xml is explained in this link http://logging.apache.org/log4j/1.2/manual.html Many examples are provided here http://wiki.apache.org/logging-log4j/Log4jXmlFormat. To cut the short story even shorter, the below xml directs all output from any class under my.package.* to the SERVER-FILE. ?xml version=1.0 encoding=UTF-8? !DOCTYPE log4j:configuration SYSTEM log4j.dtd log4j:configuration xmlns:log4j=http://jakarta.apache.org/log4j/; debug=false !-- server log file, for server use -- appender name=SERVER-FILE class=org.jboss.logging.appender.DailyRollingFileAppender param name=File value=app-server.log/ param name=Append value=true/ /appender !--INFO and above goes to the file -- category name=my.package priority value=INFO/ appender-ref ref=SERVER-FILE/ /category root appender-ref ref=SERVER-FILE/ /root /log4j:configuration
AW: How to filter the unnecessary log messages
Either you strongly restrict the level of your root logger (e.g. ERROR) and declare a logger for your own classes with DEBUG level: logger name=my.company additivity=false level value=DEBUG/ (appender-refs) /logger root level value=ERROR/ (appender-refs) /root Or you go the other way round, you restrict the library loggers strongly and configure the root logger to DEBUG: logger name=org.springframework additivity=false level value=WARN/ (appender-refs) /logger logger name=org.hibernate additivity=false level value=ERROR/ (appender-refs) /logger logger name=org.hibernate additivity=false level value=info/ (appender-refs) /logger logger name=org additivity=false level value=info/ (appender-refs) /logger root level value=DEBUG/ (appender-refs) /root -Ursprüngliche Nachricht- Von: Harikrishna Imadabattina [mailto:harikrishna.imadabatt...@techendeavour.com] Gesendet: Montag, 9. März 2009 12:58 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - How to filter the unnecessary log messages - Bayesian Filter detected spam Hi all, I have implemented log4j and it works well. But the application had Struts2, Spring,Hibernate,Tiles and other open source components. When I start the tomcat or run the application the log file gets filled with so many logs which are there inside jars of these frameworks. Can any one please let me know how can I filter out those messages and enable only application specific messages to appear in the log file. Please find the log pasted below. Thanks Harry - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Using log4j.properties to handle other properties
My developers are using System Properties to enable certain trace options (like collecting statistics) Is there a way I could define such property in the log4j.properties instead so we keep trace/log options and metadata together ? So my developers will do aLog 4J object.getProperty('my property') instead of System.getProperty() ? Christophe Elek - Senior Software Analyst IBM Rational Serviceability Architect IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 Phone Number: (905) 413-3467 Email: ce...@ca.ibm.com Rational Internal Serviceability Portal Don't just fix the mistakes - fix whatever permitted the mistake in the first place. Charles Fishman Web:http://www.ibm.com/software/rational/
AW: [SPAM (Bayesain Analysis)] - Using log4j.properties to handle other properties - Bayesian Filter detected spam
I assume you mean following (pseudo code) If SystempropertyCollectStatistics==True myLog.info( ... ) The correct way would be to use a special named logger and declare it in the propeties file with the desired log level. Possible code in class with statstic logging needs: Logger myNormalDebugLogger = Logger.getLogger( CLASS ); Logger myStatisticLogger = Logger.getLogger( StatisticLogger ) static int count = 0; void foo() myNormalDebugLogger.debug( entering foo()... ); count++; if myStatisticLogger.isInfoEnabled() myStatisticLogger.info( foo() called now + count + times ); ... Within the configuration file you can enable the statistics by setting the level of StatisticLogger to INFO, disable it by setting it to WARN or OFF. Heri -Ursprüngliche Nachricht- Von: Christophe Elek [mailto:ce...@ca.ibm.com] Gesendet: Montag, 9. März 2009 15:09 An: log4j-user@logging.apache.org Betreff: [SPAM (Bayesain Analysis)] - Using log4j.properties to handle other properties - Bayesian Filter detected spam My developers are using System Properties to enable certain trace options (like collecting statistics) Is there a way I could define such property in the log4j.properties instead so we keep trace/log options and metadata together ? So my developers will do aLog 4J object.getProperty('my property') instead of System.getProperty() ? Christophe Elek - Senior Software Analyst IBM Rational Serviceability Architect IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 Phone Number: (905) 413-3467 Email: ce...@ca.ibm.com Rational Internal Serviceability Portal Don't just fix the mistakes - fix whatever permitted the mistake in the first place. Charles Fishman Web:http://www.ibm.com/software/rational/ - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org