## LOGGERS ##
#define a logger named helloAppLogger
log4j.rootLogger=DEBUG,console,file
## APPENDERS ##
# define an appender named console, which is set to be a ConsoleAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
# define an appender named file, which is set to be a RollingFileAppender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.txt
## LAYOUTS ##
# assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
# assign a PatternLayout to file appender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %t [%c]-[%p] %m%n
#log4j.appender.file.layout=org.apache.log4j.TTCCLayout
#define a logger named helloAppLogger
log4j.rootLogger=DEBUG,console,file
## APPENDERS ##
# define an appender named console, which is set to be a ConsoleAppender
log4j.appender.console=org.apache.log4j.ConsoleAppender
# define an appender named file, which is set to be a RollingFileAppender
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log.txt
## LAYOUTS ##
# assign a SimpleLayout to console appender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
# assign a PatternLayout to file appender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %t [%c]-[%p] %m%n
#log4j.appender.file.layout=org.apache.log4j.TTCCLayout
本文详细介绍了Log4j的日志配置方法,包括定义名为helloAppLogger的logger、使用ConsoleAppender和RollingFileAppender两种appender,以及如何为这两种appender分配不同的布局方式。通过这些配置,可以实现灵活的日志记录和查看。
1269

被折叠的 条评论
为什么被折叠?



