日期:2014-05-20 浏览次数:20761 次
log4j.rootCategory=WARN,R #log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%p [%d{yyyy-MM-dd HH:mm:ss}] (%F:%L)%n%m%n%n log4j.appender.R=org.apache.log4j.FileAppender log4j.appender.R.File=/u04/software/tomcat/webapps/prdquot/logs/log4jlog.log log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p [%d{yyyy-MM-dd HH:mm:ss}]%n%m%n%n #log4j.appender.R.File=I:/tomcat/webapps/prdquot/logs/log4jlog.log log4j.appender.R.MaxFileSize=20480KB log4j.appender.R.threshold=ERROR
og4j.rootLogger=DEBUG, stdout, RFA log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Threshold=DEBUG log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p: [%d] %c{1} - %m%n # Appender RFA writes to the file "my.log" in tomcat's logs dir log4j.appender.RFA=org.apache.log4j.RollingFileAppender log4j.appender.RFA.File=${CATALINA_HOME}/logs/my.log log4j.appender.RFA.MaxFileSize=200KB # Keep one backup file log4j.appender.RFA.MaxBackupIndex=10 # Don't truncate if log file aleady exists. log4j.appender.RFA.Append=true # Appender RFA uses the PatternLayout. log4j.appender.RFA.layout=org.apache.log4j.PatternLayout log4j.appender.RFA.layout.ConversionPattern=%5p: [%d] %c{1} - %m%n
------解决方案--------------------
确定当前用户在指定日志文件所在的文件夹具有写权限
------解决方案--------------------
### set log levels ###
log4j.rootLogger = info ,stdout, D
### \u8f93\u51fa\u5230\u63a7\u5236\u53f0 ###
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{yyyy-MM-dd HH:mm:ss,SSS} [%p]-[%c] %m%n
### \u8f93\u51fa\u5230\u65e5\u5fd7\u6587\u4ef6 ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = /usr/Lottery/tomcat/logs/log.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = info
## \u8f93\u51faDEBUG\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [%p]-[ %t:%r ] %m%n
### \u4fdd\u5b58\u5f02\u5e38\u4fe1\u606f\u5230\u5355\u72ec\u6587\u4ef6 ###
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = /usr/Lottery/tomcat/logs/error.log
## \u5f02\u5e38\u65e5\u5fd7\u6587\u4ef6\u540d
log4j.appender.D.Append = true
log4j.appender.D.Threshold = ERROR
## \u53ea\u8f93\u51faERROR\u7ea7\u522b\u4ee5\u4e0a\u7684\u65e5\u5fd7!!!
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [%p]- [ %t:%r ] %m%n
这个是我以前用过的,项目也是部署在linux下,你可以参考一下