log4j - log4j2:如何在不重新启动应用程序的情况下在月/日文件夹中创建日志
问题描述
我有以下 log4j2.xml 文件。在启动程序时,它会为每个月创建新文件夹。但我想登录新月文件夹(如果月份已更改),而不需要每月重新启动程序。
<RollingFile name="info-log"
fileName="${sys:exportLoggingPath}/INFO/${date:yyyy}/${date:yyyy-MM}/Recent.log"
filePattern="${sys:exportLoggingPath}/INFO/${date:yyyy}/${date:yyyy-MM}/%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{yyyy-MM-dd HH:mm:ss}\t admin \t%X{itemType}\t%X{operationType}\t%m\t%X{traceID}%n</pattern>
</PatternLayout>
<Filters>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL" />
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL" />
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL" />
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" />
</Filters>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
<SizeBasedTriggeringPolicy size="5 MB" />
</Policies>
<DefaultRolloverStrategy max="9999999" />
</RollingFile>
解决方案
推荐阅读
- python - 保证非零相等时的 Numpy 2d 数组联合
- javafx - JavaFX 如何在 CSS 中设置高斯模糊
- python - 部署为包时 Python 导入错误
- python - How to patch an asynchronous class method?
- python-3.x - 安装 pyrebase 时出错
- php - Deploying Laravel 5.4 to Shared Hosting
- csv - Spark 读取 csv 文件时出错
- r - Extract error matrix from manova analysis in r
- sql - Case expression for date format conversion
- visual-studio - Can't add source directory for Intellisense