How to Compress Log4J's Log File

I’m using log4j’s DailyRollingFileAppender which would create a new log file everyday. Each file’s size is around 100 to 200MB, and I see the log files folder is growing bigger and bigger every day.

My solution to them is to compress everyday’s log into gzip, gz or perhaps into zip file. Basically, im using one of log4j’s companion.

So here is my solution, first a simple pom.xml to download the libraries needed.

<project xmlns="" xmlns:xsi=""

And then my file, please take a look at line 7. It will create a new log file for every second, change it into yyyyMMdd if you want to create a daily appender.

log4j.rootLogger=DEBUG, request
log4j.appender.request.RollingPolicy.ActiveFileName =msg.log
log4j.appender.request.layout = org.apache.log4j.PatternLayout
log4j.appender.request.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n