How do I change the folder in which a snap sends its logs

I am running rocketchat via snap on Ubuntu 18.04, snap version 2.47.1.
I want to send all my snap logs to /home/madeti/logs folder instead of /var/log because of disk space issues.

I have already symlinked the folder /var/log to point to /home/madeti/logs and it is working fine for all other applications (syslog, elasticsearch, nginx etc.) but starting a snap results in the following error (which I am copying from syslog):

apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="/snap/core/10185/usr/lib/snapd/snap-confine" name="/tmp/snap.rootfs_pRGXOp/var/log/" pid=10892 comm="snap-confine" srcname="/home/madeti/logs/" flags="rw, rbind"
cannot perform operation: mount --rbind /var/log /tmp/snap.rootfs_pRGXOp//var/log: Permission denied

Any help is appreciated.

try to use bind mounts instead of symlinks …

Thanks. Bind mount worked.

1 Like