# 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 = 123@qq.com 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= 456@qq.com log4j.appender.mail.layout=org.apache.log4j.PatternLayout log4j.appender.mail.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
log4j.properties