Linux-Java logs rotating using log4j or logrotate.d Linux-Java logs rotating using log4j or logrotate.d linux linux

Linux-Java logs rotating using log4j or logrotate.d


In general, I usually use log4j for logging and initial rotations, and I use logrotate for compression and archiving. The reason is that I try and keep the logging rules, including which file(s) to log, size, naming convention, etc. to be associated with the application.I then try and put the sysadmin type configurations, like how many to keep, when to compress, when to move to backup directory in the logrotate.


There is no equivalent for logrotate on Windows (see https://serverfault.com/questions/358172/equivalent-of-logrotate-for-windows). So if you ever plan to run your Java application on Windows, log4j is the only option you have for configuring log rotation.