我需要配置log4j.xml,使得具有此格式的当前日志文件(例如trans-20170517)每天都会更改并保存前一天的文件。
我想要生成日志的示例:trans-20170516.log(昨天)trans-20170517.log(当前日志)
请参阅下面的xml格式:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Properties>
<Property name="log-path">C:/Users/glopega/Desktop/ItemError</Property>
<Property name="log-file-name">transactions</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${log-path}/${log-file-name}-${date:yyyyMMdd}.log" filePattern="${log-path}/${log-file-name}-%d{yyyyMMdd}.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd kk:mm:ss},%m%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"
modulate="true" />
<OnStartupTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="999" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="root" level="debug" additivity="false">
<appender-ref ref="RollingFile" level="debug" />
</Logger>
<Root level="debug" additivity="false">
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>