log4j.appender.xiaozhi.File =org.apache.log4j.DailyRollingFileAppenderlog4j.appender.xiaozhi.File.file =d:\\xiaozhi.loglog4j.appender.xiaozhi.File.DatePattern =.yyyy-MM-ddlog4j.appender.xiaozhi.File.layout =org.apache.log4j.PatternLayoutlog4j.appender.xiaozhi.File.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss,SSS} %5p (%C:%M) - %m%nlog4j.appender.xiaozhi.Console =org.apache.log4j.ConsoleAppender log4j.appender.xiaozhi.Console.layout =org.apache.log4j.PatternLayout log4j.appender.xiaozhi.Console.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss,SSS} %5p (%C:%M) - %m%n log4j.rootLogger=error,xiaozhi.File,xiaozhi.Console #log4j.logger.com.xiaozhi=debug,xiaozhi.Console,xiaozhi.File #log4j.logger.com.xiaozhi.dao=error,xiaozhi.Console,xiaozhi.File
Appender、Layout、Logger三者之间的关系
1、每个appender后面必然需要跟随layout,指定自己的风格样式
2、每个Logger都可以指定一个级别,同时引用多个Appender
3、每个Appender也同时可以被多个Logger引用