How to rotate elastic log files using logrotate instead of log4j

Hi,

This is to answer a question I've been working on this morning and found no good answers for using google.

We put our logs into a cloud log solution. We're using a collection agent (fluentd) to slurp all files matching /var/log/**/*.log and use logrotate(8) for the rotation and deletion after one day. This is convenient and also ensures part of our GDPR compliance: we don't keep log files around and retention and access to the files are managed in the cloud (sorry, not elk).

Changing all instances of RollingFile to File in the supplied log4j2.properties file stops log4j from rotating the files. Writing a logrotate configuration is relatively easy. As far as I can tell you should use the copytruncate option when rotating the files.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.