# 日志输出级别+输出方式 log4j.rootLogger=INFO, stdout, logfile # 控制台打印设置 log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n # 文件打印设置 log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=D:/logs/log4j.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
程序运行测试:
.png)]
文件: