How to redirect log4j logging from catalina.out to

2019-08-07 10:21发布

Have created log4j.properties file in my project as below, but the log file(test-service.log) is not getting created instead the log messages are getting logged in catalina.out how to resolve this.......


    log4j.debug=TRUE
    log4j.rootLogger=WARN, R
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=/opt/apache-tomcat-7.0.40/logs/test-service.log
    log4j.appender.R.MaxFileSize=1000KB
    log4j.appender.R.MaxBackupIndex=5
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSSS}-%t-%x-%-5p-%-10c:%m%n 

1条回答
Juvenile、少年°
2楼-- · 2019-08-07 10:50
  1. Add log4j-1.2.17.jar to WEB-INF/lib.
  2. Move log4j.properties to the root of your src directory.
  3. Initialize a logger in your classes like:

    private static final Logger LOG = Logger.getLogger(ClassName.class);

查看更多
登录 后发表回答