You can create your own Appender that extends org.apache.log4j.RollingFileAppender and overrides the current logic by implementing your own optimized version of the implementation. Replace the current file and drop it into another log file (standard implementation of RollingFileAppender). Example:
log4j.appender.{name}=br.com.sample.MyZipRollingFileAppender
You can google and look for implementation examples using java.util.zip.ZipOutputStream or java.util.zip.GZIPOutputStream to pin the current file.
source share