How to manage Nextcloud snap logs

Managing Nextcloud snap logs

Managing Nextcloud snap logs

Nextcloud snap logs

In the event of an issue the Nextcloud logs could help figure out a probable cause. Most activities and actions in Nextcloud are logged. An automated log rotation mechanism within Nextcloud clears and retains the logs regularly to prevent an overflow.

TIP

Apps for viewing logs:
Use your favourite viewer less, more, head, tail, cat, bat or lnav to view logs,
" less is more, from head to tail with cat or bat but lnav is the way to go! "

sudo lnav /var/snap/nextcloud/current/logs/nextcloud.log

Watch Nextcloud snap log (live)

sudo nextcloud.occ log:watch

Truncate logs

Sometimes truncating the logs and waiting for the entry to reappear makes those entries more readable, since truncating the logs removes old entries and reduces overhead. Truncating your logs is definitely preferred to deleting the logs.

sudo truncate -s 0 /var/snap/nextcloud/current/logs/nextcloud.log

Nextcloud snap log locations

  • Logs for Nextcloud: /var/snap/nextcloud/current/logs/nextcloud.log
    • Note that this wonโ€™t be the case if youโ€™ve configured a custom data directory, for example somewhere in /media. The nextcloud logs will then be stored on that same directory.
  • Logs for Apache2: /var/snap/nextcloud/current/logs/apache_access.log
  • Logs for Redis: /var/snap/nextcloud/current/logs/redis.log
  • Logs for PHP-FPM: /var/snap/nextcloud/current/logs/php-fpm_errors.log
  • Logs for PHP: /var/snap/nextcloud/current/logs/php_errors.log
  • Logs for Certbot: /var/snap/nextcloud/current/certs/certbot/logs/letsencrypt.log
  • Logs for MySQL: /var/snap/nextcloud/current/logs/mysql_errors.log

Nextcloud snap service logs

Nextcloud snap has several services contained within it. There are four that are most important for upgrade purposes:

  • MySQL (nextcloud.mysql)
  • PHP (nextcloud.php-fpm)
  • Apache (nextcloud.apache)
  • Nextcloud Fixer (nextcloud.nextcloud-fixer)

MySQL log

sudo snap logs -f nextcloud.mysql

PHP log

sudo snap logs -f nextcloud.php-fpm

Apache log

sudo snap logs -f nextcloud.apache

Nextcloud Fixer log

sudo snap logs -f nextcloud.nextcloud-fixer

Issue debugging script

Run the following command (copy and paste the entire thing into your terminal and press enter). Paste the output into the issue; itโ€™s pre-formatted to be a nice comment, so only make it an attachment if itโ€™s too long to be a comment.

Debugging script