Log rotation in Kubernetes environment

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Hi, everyone.

I have Nextcloud deployed in Kubernetes, works fine, but I can’t understand how can I do a log rotation when NC works in more than one replica.

My setup:

  • two replicas of NC
  • CronJob with php -f /var/www/html/cron.php --verbose command
  • Custom logs for nextcloud.log and admin_audit.log
'logfile' => '/tmp/nextcloud.log',
'logfile_audit' => '/tmp/admin_audit.log'
'log_rotate_size' => 104857600

So, CronJob doesn’t have access to /tmp оf each replica, it’s executed in own environment.

Another way is to write logs into PVC, but how can I understand which replica write into log file? There is no special field in the log, like Hostname or something else