log4j 配置 文件保存日志

#全局日志等级配置,输出位置


log4j.rootLogger=info, error, stdout,logfile


#stdout控制器


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=%d %p [%c]:%L - %m%n


#文件路径输出


log4j.appender.logfile=org.apache.log4j.RollingFileAppender


log4j.appender.logfile.encoding=UTF-8


log4j.appender.logfile.File=${catalina.base}/logs/test.log


log4j.appender.logfile.MaxFileSize=512KB


# Keep three backup files.


log4j.appender.logfile.MaxBackupIndex=3


# Pattern to output: date priority [category] - message


log4j.appender.logfile.layout=org.apache.log4j.PatternLayout


log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

你可能感兴趣的:(Java)