2 Minutes To Code (β Version)

Log4j - 2 minute tutorial

How to make log files rotate every day using log4j.properties

The log4j.properties file given below will create one log file per day, with name like example-20120801.log, example-20120802.log etc in d:/logs folder.The file will rollover at 12AM everyday.

To make the file rollover per month, per hour or per minute, only the DatePattern needs to be changed to yyyyMM/yyyyMMddHH/yyyyMMddHHmm respectively as shown in the next example