我正在使用 Log4j/log4j extras 来记录日志。这里是配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="fileAppender" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="append" value="true" />
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
<param name="minIndex" value="1"/>
<param name="maxIndex" value="10"/>
<param name="FileNamePattern" value="/appserver/Logs/Logs1/log.%i.gz"/>
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="maxFileSize" value="1000000000"/><!-- 1GB -->
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd MMM yy HH:mm:ss:SSS}] [%p] - [%t %l]- %m%n" />
</layout>
</appender>
<!--disable logging from the library Jars -->
<category name="org.apache.velocity">
<priority value="off" />
</category>
<category name="com.someting.www">
<priority value="off" />
</category>
<category name="org.apache">
<priority value="off" />
</category>
<root>
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</root>
</log4j:configuration>
我希望日志仅出现在文件中,但我将日志写入文件和控制台中。请提出更改以获得预期结果。