log4j2-2 appenderfile。我只使用一个参考,但生成了两个文件(其中一个是空的)
我有两个“滚动文件”这样的附录:
<RollingFile name="fileDebug" fileName="${REP}/debug.log" filePattern="${REP}/debug-%d{yyyy-MM-dd}-%i.log">
<Filters>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="2"/>
</RollingFile>
<RollingFile name="fileInfo" fileName="${REP}/info.log" filePattern="${REP}/info-%d{yyyy-MM-dd}-%i.log">
<Filters>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="2"/>
</RollingFile>
我只称其中一个。例如
<Loggers>
<Root level="all">
<appender-ref ref="fileDebug"/>
</Root>
</Loggers>
,但是,当我运行程序时,生成了2个文件: debug.log 带日志和一个空的 info.log
我只能只有一个文件(调试。 log)在此配置中?
非常感谢
I have two appenders "RollingFile" like this :
<RollingFile name="fileDebug" fileName="${REP}/debug.log" filePattern="${REP}/debug-%d{yyyy-MM-dd}-%i.log">
<Filters>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="2"/>
</RollingFile>
<RollingFile name="fileInfo" fileName="${REP}/info.log" filePattern="${REP}/info-%d{yyyy-MM-dd}-%i.log">
<Filters>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_PATTERN}"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="2"/>
</RollingFile>
And I call only one of them. For example
<Loggers>
<Root level="all">
<appender-ref ref="fileDebug"/>
</Root>
</Loggers>
But, when I run my program, 2 files are generated : debug.log with logs and an empty info.log
How can I have only one file (debug.log) in this configuration ?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

最后,我将这种配置与记录级别调整为$ {级别}进行此配置
Finally, I make this configuration with the logging's level adjusted to ${LEVEL}