如何压缩只有旧的滚动文件,而不是每次滚动?(现在是每天)。下面的配置只每天滚动,60天后删除压缩文件,但每天压缩。
我不想使用工具来解压缩最近[X]天的文件,如果我必须在其中进行调查…
<RollingRandomAccessFile name="file" fileName="${baseDir}/app-trace.log"
filePattern="${baseDir}/app-trace-%d{yyyy-MM-dd}.log.gz"
immediateFlush="false" append="true">
<PatternLayout pattern="%d %-5p [%t] %c - %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="91">
<Delete basePath="${baseDir}" maxDepth="2">
<IfFileName glob="*/app-trace*.log.gz">
<IfLastModified age="60d">
<IfAny>
<IfAccumulatedFileSize exceeds="1 GB"/>
<IfAccumulatedFileCount exceeds="10"/>
</IfAny>
</IfLastModified>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
我有一个类似的问题,我最终做了我自己的DeleteAction实现,并将其附加到DefaultRolloverStrategy,以便在删除之前压缩所有内容。您可以在
找到源代码。https://github.com/lqbweb/log4j2-ZipDelete