log4j2无法正常工作,创建2个具有相同名称的文件。压缩的人很折断
我正在使用sizebasedtriggeringpolicy
和timebasedtriggeringpolicy
均为我的应用程序的log4j2 for my应用,with sever xml:
<RollingRandomAccessFile name="app_log" fileName="logs/app.log"
filePattern="logs/app-%d{yyyy-MM-dd'T'HH:mm':00Z'}.%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] [%X{opc-request-id}] %replace{%m}{[\n\r]+}{} %ex{full}{separator( | )}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="60" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="20">
<Delete basePath="logs/" followLinks="True">
<IfFileName glob="app-*.log*">
<IfAny>
<IfLastModified age="14d"/>
<IfAccumulatedFileSize exceeds="6 GB"/>
</IfAny>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
但是此策略无法正常工作。我可以看到很少的大小&gt; 251 MB。这些类型的文件有两个副本,一个是压缩的,而没有压缩。 在此处输入映像说明
这些类型的文件虽然很少,但是它们正在增加主机空间。有人可以帮助我了解我在这里缺少的东西吗?感谢您的帮助。
I am using SizeBasedTriggeringPolicy
and TimeBasedTriggeringPolicy
both with Log4j2 for my app with following XML:
<RollingRandomAccessFile name="app_log" fileName="logs/app.log"
filePattern="logs/app-%d{yyyy-MM-dd'T'HH:mm':00Z'}.%i.log.gz">
<PatternLayout>
<Pattern>%d %p %c{1.} [%t] [%X{opc-request-id}] %replace{%m}{[\n\r]+}{} %ex{full}{separator( | )}%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="60" modulate="true"/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="20">
<Delete basePath="logs/" followLinks="True">
<IfFileName glob="app-*.log*">
<IfAny>
<IfLastModified age="14d"/>
<IfAccumulatedFileSize exceeds="6 GB"/>
</IfAny>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
But this policy is not working as expected. I can see few files with size > 251 MB. There are two copy of these types of files one is compressed and other without compression.
enter image description here
These type of files are very less though but they are increasing host space. Can somebody please help me understand what i am missing here. Appreciate your help in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论