log4j配置文件使用
log4j 配置文件使用原则
# log4j.debug=ture //是否打开log4j的内部日志打印 # 父logger,级别为info,指定控制台输出器 log4j.rootLogger=info, console # 配置子logger,目的就是控制一定范围内的日志输出,比如这里的子logger是控制cn.server.test包下面的所有类的日志输出,其父logger就是rootLogger log4j.logger.cn.server.test=error,E # 信息是否输出到父logger log4j.additivity.cn.server.test=false # 输出器配置 log4j.appender.E = org.apache.log4j.DailyRollingFileAppender log4j.appender.E.File =G://logs/error.log log4j.appender.E.Append = true log4j.appender.E.Threshold = ERROR log4j.appender.E.layout = org.apache.log4j.PatternLayout log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n # (ConsoleAppender:控制台打印) log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n # (DailyRollingFileAppender) log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File = G://logs/log.log log4j.appender.D.Append = true log4j.appender.D.Threshold = DEBUG log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n # (mail) log4j.appender.mail=org.apache.log4j.net.SMTPAppender log4j.appender.mail.Threshold=DEBUG log4j.appender.mail.BufferSize=10 log4j.appender.mail.From = log4j.appender.mail.SMTPHost=smtp.qq.com log4j.appender.mail.Subject=Log4J Message log4j.appender.mail.SMTPUsername=123 log4j.appender.mail.SMTPPassword=xxx log4j.appender.mail.To= log4j.appender.mail.layout=org.apache.log4j.PatternLayout log4j.appender.mail.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
相关推荐
chw0 2020-11-04
sdaq 2020-07-26
MrLiar 2020-07-07
sdaq 2020-06-16
丨Fanny丨Cri 2020-06-13
CXC0 2020-06-08
MrLiar 2020-06-04
丨Fanny丨Cri 2020-06-03
丨Fanny丨Cri 2020-05-17
JavaWinner 2020-05-10
JavaWinner 2020-05-04
CXC0 2020-04-20
CXC0 2020-04-10
丨Fanny丨Cri 2020-02-18
MrLiar 2020-02-16
CXC0 2020-02-09