Log4j Sample1

log4j

In this example below, we use two appenders named logfile and debug1:

# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=DEBUG,logfile,debug1
#log4j.rootCategory=FATAL,logfile1,logfile
#log4j.rootCategory=FATAL,logfile1,logfile,debug1
##log4j.rootCategory=INFO,logfile1,logfile
#log4j.rootCategory=INFO,logfile1,logfile,debug1

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.debug1=org.apache.log4j.ConsoleAppender
log4j.appender.debug1.Threshold=INFO
log4j.appender.debug1.layout=org.apache.log4j.PatternLayout
log4j.appender.debug1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.Threshold=INFO
log4j.appender.logfile.File=submitter.log
log4j.appender.logfile.ImmediateFlush=true
#log4j.appender.logfile.Append=false
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
log4j.appender.logfile.MaxFileSize=10000KB
log4j.appender.logfile.MaxBackupIndex=50

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.logfile1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile1.Threshold=INFO
log4j.appender.logfile1.File=submitter1.log
log4j.appender.logfile1.ImmediateFlush=true
log4j.appender.logfile1.Append=false
log4j.appender.logfile1.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile1.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
#log4j.appender.logfile=org.apache.log4j.FileAppender
#log4j.appender.logfile.File=queue.log
#log4j.appender.logfile.Append=true
#log4j.appender.logfile.Threshold=INFO
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
#log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.logfile.File=queue.log
#log4j.appender.logfile.ImmediateFlush=true
#log4j.appender.logfile.Append=false
#log4j.appender.logfile.Threshold=INFO
#log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
#log4j.appender.logfile.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
##log4j.appender.logfile.DatePattern='.'yyyy-MM-dd-HH-mm
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License