日志文件搞砸了(日志一次写入多个相同的日志文件)

时间:2016-06-21 02:00:04

标签: java logging log4j

为了不同的目的,我们在项目中配置了log4j(版本1.2.15)和log4j.properties。我们正面临着日志文件编写的问题。如果您查看以下文件,它们不是有序的,并且日志一次写入多个文件。最初它们看起来很好,但是在一段时间之后它发生了,由于这个原因,我们无法调试问题。

web@:/prod/sys/web/vapprev/logs> ls -ltre | grep web

-rw-r--r--   1 web webgroup 1024135 Jun 20 11:45:06 2016 webpass.log.10
-rw-r--r--   1 web webgroup 1024052 Jun 20 11:51:45 2016 webpass.log.9
-rw-r--r--   1 web webgroup 1024273 Jun 20 13:05:05 2016 webpass.log.8
-rw-r--r--   1 web webgroup 1024030 Jun 20 13:07:04 2016 webpass.log.7
-rw-r--r--   1 web webgroup 1024111 Jun 20 13:07:33 2016 webpass.log.6
-rw-r--r--   1 web webgroup 1026339 Jun 20 14:54:14 2016 webpass.log.5
-rw-r--r--   1 web webgroup 1024445 Jun 20 14:54:22 2016 webpass.log.3
-rw-r--r--   1 web webgroup 1024201 Jun 20 15:30:44 2016 webpass.log.2
-rw-r--r--   1 web webgroup    1080 Jun 20 15:39:30 2016 webpass.log
-rw-r--r--   1 web webgroup   66420 Jun 20 15:39:53 2016 webpass.log.4
-rw-r--r--   1 web webgroup   72414 Jun 20 15:39:54 2016 webpass.log.1



web@pnjdvgnapp1:/prod/sys/web/vapprev/logs> ls -ltre | grep web

-rw-r--r--   1 web webgroup 1024135 Jun 20 11:45:06 2016 webpass.log.10
-rw-r--r--   1 web webgroup 1024052 Jun 20 11:51:45 2016 webpass.log.9
-rw-r--r--   1 web webgroup 1024273 Jun 20 13:05:05 2016 webpass.log.8
-rw-r--r--   1 web webgroup 1024030 Jun 20 13:07:04 2016 webpass.log.7
-rw-r--r--   1 web webgroup 1024111 Jun 20 13:07:33 2016 webpass.log.6
-rw-r--r--   1 web webgroup 1026339 Jun 20 14:54:14 2016 webpass.log.5
-rw-r--r--   1 web webgroup 1024445 Jun 20 14:54:22 2016 webpass.log.3
-rw-r--r--   1 web webgroup 1024201 Jun 20 15:30:44 2016 webpass.log.2
-rw-r--r--   1 web webgroup   68580 Jun 20 15:42:53 2016 webpass.log.4
-rw-r--r--   1 web webgroup   74574 Jun 20 15:42:54 2016 webpass.log.1
-rw-r--r--   1 web webgroup    3600 Jun 20 15:43:00 2016 webpass.log

以下是log4j.properties

/vgn-ext-templating.war/WEB-INF/classes/log4j.properties

****************************************
        ###Product Logs
        log4j.logger.com.vignette.ext.templating.cache=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.util=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.taglib=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.client.javabean=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.portal.webservice=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.link=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating.ui.widget.ck=DEBUG, DPMLOG
        log4j.logger.com.vignette.ext.templating=DEBUG, DPMLOG
        log4j.additivity.com.vignette.ext.templating=false
        log4j.logger.com.vignette.vps.dpsext=DEBUG, DPMLOG

        #Webpass application Logs
        log4j.logger.com.test.webpass=DEBUG, DPMLOG
        log4j.additivity.com.test.webpass=false


        # DPMLOG is set to be a File appender using a PatternLayout.
        log4j.appender.DPMLOG=org.apache.log4j.RollingFileAppender
        log4j.appender.DPMLOG.File=${com.vignette.portal.installdir.path}/logs/webpass.log
        log4j.appender.DPMLOG.Append=true
        # added flush property on 05/23/2016
        log4j.appender.DPMLOG.ImmediatFlush=true
        log4j.appender.DPMLOG.Threshold=DEBUG
        log4j.appender.DPMLOG.MaxFileSize=1000KB
        log4j.appender.DPMLOG.MaxBackupIndex=20
        log4j.appender.DPMLOG.layout=org.apache.log4j.PatternLayout
        #log4j.appender.DPMLOG.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
        log4j.appender.DPMLOG.layout.ConversionPattern=%d %-5p %c %x - %m%n
****************************************

下面是log4j.xml,但它与上面的日志无关,因为它是在log4j.properties中配置的

*******************************************
        <?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
        <!-- main resources -->
        <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

          <loggerFactory class="org.owasp.esapi.reference.Log4JLoggerFactory"/>

            <!-- esapi appender : START -->
          <appender name="waffile" class="org.apache.log4j.RollingFileAppender">
            <param name="File" value="${com.vignette.portal.installdir.path}/logs/templating-esapi.log"/>
            <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d[%t]%-5p %m%n"/>
            </layout>
            <param name="Append" value="true"/>
            <param name="MaxFileSize" value="10000KB"/>
            <param name="MaxBackupIndex" value="20"/>
          </appender>
          <!-- esapi appender : END -->


        <!-- esapi logger  : START-->
          <logger name="org.owasp.esapi">
            <level value="INFO"/>
            <appender-ref ref="waffile" />
          </logger>
         <!-- esapi logger  : END-->


        </log4j:configuration>
**************************************************

以下是尝试的步骤

已尝试的步骤

1)尝试将所有配置移动到log4j.xml并消除了log4j.properties - 未解决 2)将log4j从log4j-1.2.15升级到log4j-1.2.16 - 未解决

谢谢, 拉朱

0 个答案:

没有答案