Compress Log4j files

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>

For more details check the Javadoc

Leave a Comment