NextCloud Logging - Log file empty

Nextcloud version: 12.0.1
Operating system and version (eg, Ubuntu 16.04): Ubuntu 16.04
Apache or nginx version (eg, Apache 2.4.25): Apache2 2.4.18-2ubuntu3.4
PHP version (eg, 5.6): php 1:7.0+35ubuntu6

The issue you are facing:
I’m trying to setup fail2ban. A part of this is to read the file /var/log/nextcloud.log for failed log in attempts. My issue is /var/log/nextcloud.log is empty. In my config.php I have:
‘log_type’ => ‘file’,
‘logtimezone’ => ‘/Europe/London’,
‘logfile’ => ‘/var/log/nextcloud.log’,
‘loglevel’ => ‘1’,

I would expect to have something there if I log in with wrong credentials, yet /var/log/nextcloud.log remains empty.

If nextcloud.log with the correct permissions does not exist, the apache-user probably does not have enough permissions to create a new file itself in /var/log

So either create a subfolder that belongs to www-data where you put NC logs, or create an empty logfile and give www-data permissions to write.

Or you use the system log and check for failed login attempts in there.
The Admin Docs for NC 12 read:

syslog

All log information will be sent to your default syslog daemon.

"log_type" => "syslog",
"logfile" => "",
"loglevel" => "3",

This would definitely help with the permissions. Because giving the file /var/log/nextcloud.log one time the necessary permissions only helps until the next log file rotation. So the better idea would then be the subfolder that tflidd mentioned.

The additional parameter could help:
'syslog_tag' = > 'Nextcloud',

That was rather silly of me, forgetting that Nextcloud would be writing rather than the system. It was the permissions issue. That’s resolved it immediately. Thank you.

1 Like