Example log4j Configuration File
/*
Logging In Java with the JDK 1.4 Logging API and Apache log4j
by Samudra Gupta
Apress Copyright 2003
ISBN:1590590996
*/
//Example log4j Configuration File
/*
#set the level of the root logger to DEBUG and set its appender
as an appender named X
log4j.rootLogger = DEBUG, X
#set the appender named X to be a console appender
log4j.appender.X=org.apache.log4j.ConsoleAppender
#set the layout for the appender X
log4j.appender.X.layout=org.apache.log4j.PatternLayout
log4j.appender.X.layout.conversionPattern=%m%n
*/
// Complex log4j Configuration File
/*
# define the root logger with two appenders writing to console and file
log4j.rootLogger = DEBUG, CONSOLE, FILE
#define your own logger named com.foo
log4j.logger.com.foo=com.foo.MyLogger
#assign appender to your own logger
log4j.logger.com.foo.appender=FILE
#define the appender named
FILE log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${user.home}/log.out
#define the appender named CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.conversionPattern=%m%n
log4j.properties
#set the level of the root logger to DEBUG (the lowest level) and
set its appender
#as an appender named X
log4j.rootLogger = DEBUG, X
#set your own logger
log4j.logger.com.apress.logging.log4j=DEBUG, X
#set the appender named X to be a console appender
log4j.appender.X=org.apache.log4j.ConsoleAppender
#set the layout for the appender X
log4j.appender.X.layout=org.apache.log4j.PatternLayout
log4j.appender.X.layout.conversionPattern=%p-%m%n
*/
Related examples in the same category