log4j2无法正常工作,创建2个具有相同名称的文件。压缩的人很折断

发布于 2025-02-07 01:06:57 字数 1560 浏览 4 评论 0原文

我正在使用sizebasedtriggeringpolicytimebasedtriggeringpolicy均为我的应用程序的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文