Saturday, December 15, 2012

Create logging using log4j

Put log4j.properties in your classpath


#Set the level of the root loger to DEBUG and set its appender log4j.rootCategory=DEBUG, CONSOLE, DAILY log4j.logger.com.dappit.Dapper.parser=ERROR log4j.logger.org.w3c.tidy=FATAL
# CONSOLE - Console Appender log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender #set the layout for the appender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n # FILE - File Appender #log4j.appender.FILE=org.apache.log4j.FileAppender #log4j.appender.FILE.File=logs/jlego.log # Define the layout for file appender #log4j.appender.FILE.layout=org.apache.log4j.PatternLayout #log4j.appender.FILE.layout.conversionPattern=%m%n # DAILY - DailyRollingFile Appender log4j.appender.DAILY=org.apache.log4j.DailyRollingFileAppender log4j.appender.DAILY.File=${catalina.home}/logs/mylog.log log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd # Define the layout for DAILY file appender log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout log4j.appender.DAILY.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n # Rolling file appender in HTML #------------------------------------------------------------------------------ # # The following properties configure the Rolling File appender in HTML. # See http://logging.apache.org/log4j/docs/api/index.html for details. # #------------------------------------------------------------------------------ log4j.appender.HTML=org.apache.log4j.RollingFileAppender log4j.appender.HTML.File=${catalina.home}/logs/mylog.html log4j.appender.HTML.MaxFileSize=100KB log4j.appender.HTML.Append=false log4j.appender.HTML.layout=org.apache.log4j.HTMLLayout log4j.appender.HTML.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n


Set this

log4j.logger.org.w3c.tidy=FATAL

Will cause org.w3c.tidy log only will shown if FATAL occurs

No comments: