log4j没有在CentOS6上创建日志文件

时间:2018-03-13 16:16:48

标签: java logging log4j centos6

我有这个log4j配置(见下文),但它没有在CentOS 6上创建mylogger.log,在CentOS 7中一切正常,这很奇怪。

我有使用rollingPolicy和triggeringPolicy,但是我在CentOS 6上遇到了这个错误。订单很好,因为它适用于CentOS 7.任何建议都可能出错?

log4j:WARN Continuable parsing error 9 and column 76
log4j:WARN Element type "rollingPolicy" must be declared.
log4j:WARN Continuable parsing error 15 and column 80
log4j:WARN Element type "triggeringPolicy" must be declared.
log4j:WARN Continuable parsing error 21 and column 13
log4j:WARN The content of element type "appender" must match "(errorHandler?,param*,layout?,filter*,appender-ref*)".
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'logfile'

和log4j.xml配置:

<appender name="logfile" class="org.apache.log4j.rolling.RollingFileAppender">
    <param name="File" value="/usr/projectx/log/mylogger.log" />
    <param name="Append" value="true" />
    <rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">

    <param name="minIndex" value="1" />

        <param name="maxIndex" value="12" />

        <param name="ActiveFileName" value="/usr/projectx/log/mylogger.log" />

        <param name="FileNamePattern" value="/usr/projectx/log/mylogger.%i.log.gz" />

    </rollingPolicy>

    <triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">

        <param name="maxFileSize" value="104857600" />

    </triggeringPolicy>

    <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="[%d{ISO8601}] %-5p %c(%L) %M (%t)- %m%n" /> 

    </layout>

</appender>

<appender name="console" class="org.apache.log4j.ConsoleAppender">

    <layout class="org.apache.log4j.PatternLayout">

        <param name="ConversionPattern" value="[%d{ISO8601}] %-5p %c(%L) %M (%t)- %m%n" /> 

    </layout>
    </appender>

<logger name="org.springframework">
    <level value="info" />
</logger>

<logger name="org.directwebremoting">
    <level value="info" />
</logger>

<logger name="com.project">
    <level value="info" />
</logger>   

<root>
    <level value="info" />
    <appender-ref ref="logfile" />
    <appender-ref ref="console" />
</root>

0 个答案:

没有答案