【发布时间】:2014-12-29 21:32:44
【问题描述】:
我对 log4j 2 中 RollingFile Appender 的文件模式有疑问。 RollingFile 需要一个 FileName 和 FilePattern,但我不知道 FilePattern 做了什么。我认为它只是被忽略了。这是我的 log4j2.xml 的一部分
<Property name="pattern">
%-5p [%d{dd.MM.yyyy - HH:mm:ss}] : %m%n %ex
</Property>
<Property name="MainLoggerPath">
C:/logs/MainLogger.log
</Property>
<Property name="FilePattern">
C:/logs/$${date:yyyy-MM}/app-%d{MM- dd-yyyy}-%i.log.gz
</Property>
<RollingFile name="MainAppender" fileName="${MainLoggerPath}"
filePattern="${FilePattern}">
<ThresholdFilter level="ALL" onMatch="ACCEPT" onMismatch="DENY" />
<PatternLayout
pattern="${pattern}" />
<Policies>
<SizeBasedTriggeringPolicy size="10 MB" />
</Policies>
<DefaultRolloverStrategy max="10" />
</RollingFile>
【问题讨论】:
标签: java apache logging log4j2