压缩 Log4j 文件 [英] Compress Log4j files

查看:37
本文介绍了压缩 Log4j 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以压缩日志文件(我通过 RollingFileAppender 压缩)?

Is it possible to compress log files (I doing it via RollingFileAppender )?

推荐答案

log4j extras对此有支持.只需将以下内容添加到您的 RollingFileAppender 配置中,并将文件名以 .gz 结尾,即可自动压缩您的日志文件:

log4j extras has support for that. Just add the following to your RollingFileAppender configuration and have the filename end in .gz to automagically compress your log files:

<appender...>
    <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
      <param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/>
    </rollingPolicy>
</appender>

有关详细信息,请查看 Javadoc

For more details check the Javadoc

这篇关于压缩 Log4j 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆