2 Minutes To Code (β Version)

Log4j - 2 minute tutorial

How to make log files rotate per day and zip old rotated logs using log4j.properties

		#Worked with 2.17 version
		log4j.rootLogger=INFO, loggerId
		log4j.appender.loggerId=org.apache.log4j.rolling.RollingFileAppender
		log4j.appender.loggerId.rollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
		log4j.appender.loggerId.rollingPolicy.ActiveFileName=worker.log
		log4j.appender.loggerId.rollingPolicy.FileNamePattern=worker-.%d{yyyyMMdd}.log.gz
		log4j.appender.loggerId.layout=org.apache.log4j.PatternLayout
		log4j.appender.loggerId.layout.ConversionPattern=%d [%t] %-5p (%F:%L) - %m%n