/var/log/nextcloudnextcloud.logand nextcloud.log.1More than one log file should be saved for archive
One file is kept.
Added nextcloud.log to logrotate using webmin and save e.g. 30 log files.
Nextcloud server version: 19.0.0
Server OS (Ubuntu server is default)
How did you install the VM? Bought with device


Hi @rakekniven
Thanks for your suggestion, I actually thought Nextcloud logs were rotated more than one time per default.
I don't know if it would be possible to add another setting to config.php which set the numbers of logs to keep?
Using Webmin isn't possible as we can't control Webmin through CLI, so it must be a CLI solution. Any suggestions?
No need to use webmin IMHO.
In /etc/logrotate.d you can place a file to do this.
Cannot give you an example right now as I do not have ssh access to my NUC.
Would that work for your scripts?
Sure, it sounds like it at least.
I don't have very much time on my hands right now, so if you want you could make a PR and make it happen faster.
I will look at this when time allows.
Add file nextcloud.log.conf to /etc/logrotate.d with the following content:
/var/log/nextcloud/nextcloud.log {
daily
rotate 30
}
This will copy your log daily and keep 30 log files.
For sure we can decrease the number if you like.
Check the source of this repo but did not find a way to add my config.
I will look at this when time allows.
Ok, it is not urgent.
Wouldn't that mess with this? https://github.com/nextcloud/vm/blob/master/nextcloud_install_production.sh#L415-L416
No, that variable sets the limit before "nextcloud.log" is copied to "nextcloud.log.1".
After that "nextcloud.log.1" will be overwritten again. So you do not get many logs.
So what you're saying is that the Nextcloud option has to be removed, and replace with logrotate?
Yes, that makes sense or set it to "0".
See https://docs.nextcloud.com/server/19/admin_manual/configuration_server/config_sample_php_parameters.html?highlight=log_rotate_size
I would argue, that 10 files a 10MB is a good size for nextcloud logs. So I would start a PR and do this:
Add file nextcloud.log.conf to /etc/logrotate.d with the following content:
/var/log/nextcloud/nextcloud.log {
daily
rotate 10
}
The question is: shall this be an option in nextcloud_configuration or server_configuation? maybe with the possibility to change the value to something own or shall it get only executed in the install_production script?
Am I missing something? is the log_rotate_size really needed? or can we just let this in there: https://github.com/nextcloud/vm/blob/e8ef2e2437567cb7ed561183ce3b0a58f98b1646/nextcloud_install_production.sh#L431
I would not set the size to 10MB.
What will happen if your log file is getting bigger than 10MB on one day?
From my understanding nextcloud will swap the file and logrotate will not save your precious log with full content.
I've set it to unrestricted (0)