[Solved] Nextcloud (snap) v12.0.4 cannot successfully change nextcloud.log location

Greetings…been working this problem for 2 days unsuccessfully with many hours of research but cannot fix.

I’m running v12.0.4 via snap install. So my nextcloud.log file is located in: /var/snap/nextcloud/common/nextcloud/data/nextcloud.log

I need it changed to /var/log/nextcloud.log because fail2ban cannot access the snap’s version location.

Steps I’ve done:

sudo nextcloud.occ config:system:set log_type --value=“owncloud”

sudo nextcloud.occ config:system:set logfile --value="/var/log/nextcloud.log"

Everything looks great in config.php:

My code:

“<?php
$CONFIG = array (
‘apps_paths’ =>
array (
0 =>
array (
‘path’ => ‘/snap/nextcloud/current/htdocs/apps’,
‘url’ => ‘/apps’,
‘writable’ => false,
),
1 =>
array (
‘path’ => ‘/var/snap/nextcloud/current/nextcloud/extra-apps’,
‘url’ => ‘/extra-apps’,
‘writable’ => true,
),
),
‘supportedDatabases’ =>
array (
0 => ‘mysql’,
),
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘/tmp/sockets/redis.sock’,
‘port’ => 0,
),
‘passwordsalt’ => ‘REDACTED-FOR-PRIVACEY’,
‘secret’ => ‘REDACTED-FOR-PRIVACEY’,
‘trusted_domains’ =>
array (
0 => ‘localhost’,
1 => ‘REDACTED-FOR-PRIVACEY’,
),
‘datadirectory’ => ‘/var/snap/nextcloud/common/nextcloud/data’,
‘overwrite.cli.url’ => ‘http://localhost’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘12.0.4.3’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost:/tmp/sockets/mysql.sock’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘nextcloud’,
‘dbpassword’ => ‘REDACTED-FOR-PRIVACEY’,
‘logtimezone’ => ‘UTC’,
‘installed’ => true,
‘instanceid’ => ‘oc1rz26caw2b’,
‘loglevel’ => 2,
‘maintenance’ => false,
‘log_type’ => ‘owncloud’,
‘logfile’ => ‘/var/log/nextcloud.log’,
);”

End My Code:

Of course I got an error log saying could not touch the /var/log/nextcloud.log due to permissions, so I did the next steps:

sudo touch /var/log/nextcloud.log
sudo chown www-data /var/log/nextcloud.log

ls -l /var/log/nextcloud.log comes back with

-rw-r–r-- 1 www-data root 0 Jan 6 08:24 /var/log/nextcloud.log

All seems ok…tested by accessing nextcloud from untrusted domain (which always gives me a level 2) in the old log and by testing with a failed login. But nothing is being logged into /var/log/nextcloud.log

I’m stumped and out of guess and research. Any ideas?

Much appreciated…

Spooky

Had no idea snaps could not read or write to the file system other than in their snap wrapper.

So I changed the directory of the log to /var/snap/nextcloud/common/nextcloud/nextcloud.log

and changed the permissions…

Now everything is working.