Configure nextcloud_access.log size

Nextcloud version: 15.0.2
Operating system and version: Debian Linux 9.11 (kernel Linux 4.14.78-4-osmc)
Apache or nginx version: Apache/2.4.25 (Debian)
PHP version: 7.0.33-0+deb9u5

The issue you are facing:

I’m using log2ram to lower the amounts of writes to the SD card of my raspberry pi 3.
It basically creates a ram disk to store the directories and files you chose.

I’ve set it up for the /var/log directory that contains, among other dirs and files, apache2 dir with nextcloud_access.log file.
At some point this files grows in size so much that it fills the whole ram disk which causes ram2log service to crash.

Is there a way to configure the size of nextcloud_access.log file?

The Nextcloud documentation seems to contain the answer on your question, see the log_rotate_size parameter.

Thanks @j-ed for pointing me in the right direction!

I tried searching the documentation with “nextcloud_access.log” before I created the topic but didn’t find anything. I guess I could have looked at the bookmarks and found the Logging section.

Anyway, I’ve added ‘log_rotate_size’ => 10 * 1024 * 1024, to nextcloud config.php file, so I hope this will resolve the issue.
I’ll report back as soon as I see if it works.

2 Likes

Is there a log rotate function available for the audit log too? The docs don’t say: https://docs.nextcloud.com/server/16/admin_manual/configuration_server/logging_configuration.html

@Gatak The same parameter “log_rotate_size” is used for the audit log. Check-out the following source code.

It seems there is a problem with this config.
This error keeps popping up in the WebUI Settings -> Logging:

{“reqId”:“AQbk4bjR1EeliUE78GpG”,“level”:3,“time”:“2019-10-25T20:05:30+00:00”,“remoteAddr”:"...",“user”:"****",“app”:“PHP”,“method”:“GET”,“url”:"/index.php/apps/logreader/poll?lastReqId=iwKoAXaACrkjbLgo9Fs5",“message”:“Use of undefined constant ‘log_rotate_size’ - assumed ‘‘log_rotate_size’’ at /var/www/nextcloud/config/config.php#34”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0”,“version”:“15.0.12.1”,“id”:“5db3558ade865”}

Btw, I’ve tried both with

‘log_rotate_size’ => 10485760,

And

‘log_rotate_size’ => 1010241024,

After looking at the formatted copy of the error, I figured out the silly mistake I made:

[PHP] Error: Use of undefined constant ‘log_rotate_size’ - assumed ‘‘log_rotate_size’’ at /var/www/nextcloud/config/config.php#34

I’ve used the wrong ’ symbol :man_facepalming:

No more error messages :slight_smile:

1 Like

Thanks. I just saw that my audit log was well over 100MB in size, multiple times larger than the normal log. I removed it and disabled the audit app. :slight_smile:

After a couple of days, I see that the nextcloud_access.log is 28 MB despite adding the ‘log_rotate_size’ => 10485760, line in the config.php.

What am I doing wrong?

Have you set-up a cron job as documented here?

Yes, it was set up long ago when I installed NextCloud and it looks like it is still working fine:

A few days ago, I’ve tried deleting the nextcloud_access.log, so it starts from scratch.
I was hoping that it won’t go over 10MB now that I’ve set up log_rotate_size.
Unfortunately it’s not 13MB.

Anyone has any ideas?

In what interval are you running your cron job?

It’s running every 15 minutes.

Are you sure /var/log/[apache2-dir]/nextcloud_access.log is the nextcloud log and not rather a logfile created by apache2? Could you post two or three lines of that logfile?

1 Like

Ok, that should definitely make sure that the limit isn’t exceeded to much. Can you please show us how the following log related variables are set in your Nextcloud configuration:

  • datadirectory
  • cron_log
  • log_type
  • logfile
  • loglevel
  • log_rotate_size

Actually I’m not sure. I assumed it was NextCloud log file because of the file’s name.
Here are a few last lines of the log file:

0.0.0.0 - User1 [14/Nov/2019:22:58:07 +0100] “GET /status.php HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:08 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:13 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:18 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:23 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:28 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:33 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:38 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User1 [14/Nov/2019:22:58:39 +0100] “GET /status.php HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:43 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:48 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -
0.0.0.0 - User2 [14/Nov/2019:22:58:53 +0100] “PROPFIND /remote.php/dav/files/User2/ HTTP/1.1” 500 -

I’ve changed the IP address to 0.0.0.0

Here is the config file. I’ve obfuscated some sensitive information.
<?php
$CONFIG = array (
‘instanceid’ => ‘—’,
‘passwordsalt’ => ‘—’,
‘secret’ => ‘—’,
‘trusted_domains’ =>
array (
0 => ‘—.----.----’,
),
‘datadirectory’ => ‘/mnt/clouddrive/nextclouddata’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘15.0.12.1’,
‘overwrite.cli.url’ => ‘https://—’,
‘dbname’ => ‘—’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘—’,
‘dbpassword’ => ‘—’,
‘installed’ => true,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘filelocking.enabled’ => ‘true’,
‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),
‘maintenance’ => false,
‘theme’ => ‘’,
‘loglevel’ => 2,
‘log_rotate_size’ => 10485760,
‘mysql.utf8mb4’ => true,
);

I’ve checked my nextcloud data directory and this is what I see:


So the log rotate works.
It seems you’re right and this is Apache2 access log.

Any way to keep it at 10MB? :slight_smile:

1 Like