Nextcloud.log is not in the right place

I have specified in the config.php file where the nextcloud.log should be created.
But it is always created on the data share.

Do I have to set something else so that the file is created in the right place?
Thank you for your help.

This is in the config.php:
‘loglevel’ => 1,
‘logfile’ => ‘/config/log/nextcloud.log’,

Is it writable for the www user? The default option is in the data directory, and I find it probable that it will use the default location if it can’t write to the file.

That sounds understandable. How can I best test this? I do not have that much experience with Nextcloud yet.
Thank you.

ls -la /config/log/nextcloud.log

check if file is there and belongs to your www user, e.g. www-data.
If not, create it with correct permissions, e.g. run it under root, or with sudo:

sudo touch /config/log/nextcloud.log

set ownership

sudo chown www-data:www-data /config/log/nextcloud.log

and set permissions to e.g. 760

sudo chmod 760 /config/log/nextcloud.log

check if it works (do activity in NC and see logs in real time)

sudo tail -f /config/log/nextcloud.log

Ok will look at this. Thanks.

hm it does not really work. After accessing nextcloud, the rights of the file are changed back again. And The file is then created again on data share and It is somehow written in both files.

root@71c47463ccf4:/# ls -la /config/log/nextcloud.log
-rwxrw---- 1 abc abc 0 Jun 22 20:19 /config/log/nextcloud.log
root@71c47463ccf4:/# ls -la /config/log/nextcloud.log
-rw-r----- 1 abc abc 831 Jun 22 20:22 /config/log/nextcloud.log

root@71c47463ccf4:/# ls -la /data/nextcloud.log
-rw-r----- 1 abc abc 29999 Jun 22 21:13 /data/nextcloud.log
root@71c47463ccf4:/# ls -la /config/log/nextcloud.log
-rw-r----- 1 abc abc 24495 Jun 22 21:10 /config/log/nextcloud.log

Not sure why it is happens. Personally I use default log place under data folder. Then just made a link to the file from my common log folder to the log file in nextcloud data folder: ln -s /pathToLog/nextcloud.log /pathToNC/data/nextcloud.log
Then adjust log rotation script to recreate it with my web user and 640 rights:

# cat /etc/logrotate.d/nextcloud.log.conf
/pathToNC/data/nextcloud.log /pathToNC/data/audit.log {
	minsize 5242880 #not rotate till around 5MB
	size 5242880 #not rotate till around 5MB
	olddir /var/log

In this case in your log folder you will see something like this:

ls -la /pathToLog/nextcloud.*
lrwxrwxrwx 1 root     root          33 Jun  4 15:37 /pathToLog/nextcloud.log -> /pathToNC/data/nextcloud.log
-rw-r----- 1 webuser webuser 1279203 Jun 21 06:00 /pathToLog/nextcloud.log.1.gz
-rw-r----- 1 webuser webuser 1252732 Jun 14 06:00 /pathToLog/nextcloud.log.2.gz
-rw-r----- 1 webuser webuser 6131822 Jun 12 06:00 /pathToLog/nextcloud.log.3.gz
-rw-r----- 1 webuser webuser 3047081 Jun 11 06:00 /pathToLog/nextcloud.log.4.gz
-rw-r----- 1 webuser webuser 3664280 Jun 10 06:00 /pathToLog/nextcloud.log.5.gz
-rw-r----- 1 webuser webuser 3050432 Jun  9 06:00 /pathToLog/nextcloud.log.6.gz
-rw-r----- 1 webuser webuser 7323984 Jun  8 06:00 /pathToLog/nextcloud.log.7.gz
-rw-r----- 1 webuser webuser 9165402 Jun  7 06:00 /pathToLog/nextcloud.log.8.gz