Problems with a big nextcloud.log

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.04 (updated a few minute ago from 31.0.02)
  • Operating system and version (e.g., Ubuntu 24.04):
    • Linux x86_64 kernel version 4.18.0-553.50.1.el8_10.x86_64
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.63
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • replace me
  • PHP version (e.g, 8.3):
    • 8.4 (I can’t remember what it was before the upgrade)
  • Is this the first time you’ve seen this error? (Yes / No):
    • replace me
  • When did this problem seem to first start?
    • replace me
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • I don't know, I only have web access through cPanel
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • I don't know

Summary of the issue you are facing:

I’ve noticed a big nextcloud.log file (151 MB) despite I’m the only user of this Nextcloud instance (I installed it to get rid of Google Drive), I’ve uploaded less then ten files and I log in once every couple of weeks. I really don’t know why NC write so much.

I’ve read some posts on this forum but didn’t find the right one. However, I discovered in config.php there are some parameters to manage (somehow…) the log files.

My config.php doesn’t have any log parameters but config.sample.php has a parameter that could help me: log_rotate_size.

In that parameter comment I read “Defaults to 100 MB”, so I guess that in my instance, where I don’t have any value in config.php for this parameter, the nextcloud.log file should have been rotated at 100 MB but I only found one file and it is 151 MB, as I wrote.

So the questions are:

  1. Why I have a 151 MB log file if it should be limited to 100 MB?
  2. If I add this parameter to my config.php and I set it to “100 * 1024 * 1024” (100 MB) what should I expect, given that I already have a 151 MB log file? Will it be renamed to something like nextcloud.1.log and stay there at 151MB?
  3. What could I expect from now on, that every time the log file reaches 100 MB it’s renamed to nextcloud.n.log and my directory will sooner or later looks like this?
nextcloud.log 
nextcloud.1.log 
nextcloud.2.log 
nextcloud.3.log
...
nextcloud.n.log 

As far as I can read in this forum there is no compression of that file.

Feel free to enrich your reply with any information you think that could be useful on how to manage NC log from the config.php file (I don’t have shell access so I can’t configure any local log rotation function).

Thanks.

Ciao,
Max

Please check your loglevel.

See Configuration Parameters — Nextcloud latest Administration Manual latest documentation for details.

Hi rakekniven, thanks for your reply.

As I wrote, my config.php file doesn’t contain any log related parameter so I guess the loglevel is 2, the default. This is confirmed in the Nextcloud GUI where i can read in

Administration -> Logging -> Log Reader Settings

that the log level is set to “Warning”.

Ciao,
Max

I can’t tell you much about the technical details of how it works, but according to the following GitHub issue, a background job is responsible for rotating the log file: [Bug]: log_rotate_size in config.php has no effect · Issue #45493 · nextcloud/server · GitHub

But to be honest, I don’t use it any more because, if I remember correctly, the rotation seemed to happen rather randomly and not exactly at the configured size. More importantly, it’s rather limited in how you can configure the rotation (only by size). Also, according to the description (see link below), it only keeps one rotated file, and it doesn’t compress the rotated file… So at some point I just turned it off and set up logrotate instead.

How it should behave is described in config.sample.php and in the corresponding part of the documentation: Configuration Parameters — Nextcloud latest Administration Manual latest documentation

I don’t think there’s much more you can do from the Nextcloud side, other than maybe identifying the background job that’s responsible for the rotation, as described in the GitHub link above, and running that manually from time to time, or maybe putting it in a separate cronjob…

EDIT:
By no means an elegant way of roatating your logs, but of course you could also download the log file manually fom time to time, and then just delete it on the server. Nextcloud will then automatically create a new one as soon as there is a new log message.

@mpolito1969
What does it say in your logs? Maybe you can rule out the cause.

Alternatively, you can delete the log file nextcloud.log and create a folder nextcloud.log. Then Nextcloud cannot create a new log file nextcloud.log. :wink: Works for me on a test Nextcloud. Alternatively, you can of course further reduce the logging with loglevel.

The logs are often neither helpful nor necessary for a single user and private data. And in the event of an error, you can reactivate them, repeat the action and then still see how the error is logged.

1 Like

Thanks to all for your replies.

As far as I can understand, NC built-in log management function still has to be improved.

I think that I’ll just have a look at that directory every couple of weeks and manually make the log rotation. I hope this problem could be addressed in one of the future releases.

Ciao,
Max

Hello @mpolito1969,
you can try the App LogCleaner. With the help of this app, you can e.g. remove all duplicate entries in the log file at once with a single click. This will certainly reduce the size considerably.
In the next version of the app, there will also be a button that will allow you to empty the entire log file without using the ssh shell.

Greetings Wolle

1 Like

Thanks so much, you solved the issue. :slight_smile:

Ciao,
Max

1 Like