Advice wanted: Log rotation without systemctl?

#1

I’m wondering if using logrotate is the best approach for rotating the logs written by our various programs in a container. All logs are written to a persistent shared volume.

We have in one container:

  • a C++ program that writes to a log file,
  • a bash script that is our dockerfile CMD and it writes to a log file,
  • a health check as bash script that also writes to a log file

In another container:

  • a tomcat host java servlet that writes logs using log4j2
  • a bash script that is our dockerfile CMD and it writes to a log file,
  • a C++ program that writes to a log file

In another container:

  • an nginx proxy that writes to access and error logs

Other than the log4j2 logging, which has the ability to rotate logs, all of the logs are being rotated using logrotate, which is if I understand it correctly requires systemctl. Which may require INITSYSTEM=0.

Is there a better way to rotate logs than using logrotate in each container? I realize that having a single container rotate all of the logs would require a single list of logs to be configured, although we could use a file pattern to rotate everything the same way.

0 Likes