server icon indicating copy to clipboard operation
server copied to clipboard

Logging stops when log file size exceeds 2 GB

Open mrkskwsnck opened this issue 9 years ago • 3 comments

I am running Nextcloud 11.0.3 on a Nextcloud Box (Ubuntu Core) installed as a Snap.

Recently I was wondering why there were no new log entries in the Logging pane of the Administrator account. Then I found out, the /var/snap/nextcloud/common/nextcloud/data/nextcloud.log file got 2 GB in size. Obviously Nextcloud could not append any new entries. After renaming the file to e.g. nextcloud.bak the original file was newly created with all new entries.

I am aware about a 2 GB file size limitation of PHP on 32 bit systems. But the log file should be rotated or stripped automatically or something like that. So I think this is a bug for sure.

Can you fix that?

mrkskwsnck avatar Jun 19 '17 20:06 mrkskwsnck

You may setup logrotate for this Task. Ich am not sure this is related to NC.

https://www.tecmint.com/install-logrotate-to-manage-log-rotation-in-linux/

Edit: Okay, one could add some code to NC to zip the logfile and create a new one ..

derkostka avatar Jun 20 '17 18:06 derkostka

There is actually some kind of logrotate in the NC-core already, but it's disabled by default. It will create one nextcloud.log.1 file after a specific filesize gets reached. Older log files will be deleted.

To see current logging settings in NC12:

# sudo -u www-data php occ log:file
Log backend file: enabled
Log file: /var/cloud/data/nextcloud.log
Rotate at: disabled

To enable logrotation at 50 MB on NC12:

# sudo -u www-data php occ log:file --rotate-size=50M
Log backend file: enabled
Log file: /var/cloud/data/nextcloud.log
Rotate at: 50 MB

Automatically enabled logrotate value should be considered on new NC-setups. (Maybe at 250 MB?)

patschi avatar Jun 20 '17 23:06 patschi

I really wasn't aware there is already a log file rotation option built into Nextcloud. Now I activated it. Thanks @patschi!

mrkskwsnck avatar Jun 21 '17 20:06 mrkskwsnck