在Windows Tomcat下部署的log4j日志自动保存到Tomcat下的logs目录下,如果不熟悉Linux的日志输出方式,那么很有可能找不到对应的日志。这篇文章讲述的是如何去找Linux配置的应用输出日志。Linux下配置路径默认是系统路径。
log4j.properties配置
log4j.rootLogger=INFO, Console,RollingFile, D #Consolelog4j.appender.Console=org.apache.log4j.ConsoleAppenderlog4j.appender.Console.layout=org.apache.log4j.PatternLayoutlog4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n log4j.logger.java.sql.ResultSet=INFOlog4j.logger.org.apache=INFOlog4j.logger.java.sql.Connection=debuglog4j.logger.java.sql.Statement=debuglog4j.logger.java.sql.PreparedStatement=debug### u8f93u51fau65e5u5fd7u5230u6587u4ef6 ### log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.RollingFile.File=logs/fmcgwms.loglog4j.appender.RollingFile.layout=org.apache.log4j.PatternLayoutlog4j.appender.RollingFile.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n### u8f93u51fau5f02u5e38u5230u6307u5b9au6587u4ef6 ### log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File = logs/fmcgwms_error.log ## log4j.appender.D.Append = true log4j.appender.D.Threshold = ERROR log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = %d [%t] %-5p [%c] - %m%n %m%n
Windows Tomcat日志输出
Windows下采用的是Tomcat的相对路径,如:C:AppTomcatapache-tomcat-7.0.62logs,即${TOMCAT_HOME}/logs
Linux Tomcat输出日志
Linux下采用的路径是系统的绝对路径:跟上面log4j配置的路径一致
logs/fmcgwms.log #相当于是/logs/fmcgwms.log