How to enable logging in Nextcloud 16


If you need to troubleshoot Nextcloud, your first task should be to enable logging. Find out how.

How to enable logging in Nextcloud 16
If you need to troubleshoot Nextcloud, your first task should be to enable logging. Find out how.

If you rely on Nextcloud as your on-premises cloud platform, you’ve probably discovered how flexible and reliable that tool is. And if you administer Nextcloud, you really understand that sentiment. 

However, you might have also discovered that, out of the box, Nextcloud doesn’t have logging enabled. This can be problematic … especially when you’re trying to troubleshoot a problem or two. Without logging enabled, where do you turn for information about issues? 

Instead of scrambling to solve those problems without the proper data for your quest, let’s make it easy and enable logging. Once you have this feature up and running, your troubleshooting will be exponentially easier.

SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)

What you need

The only things you’ll need for this are:

  • A working instance of Nextcloud.
  • A user account (on the Nextcloud server) with sudo privileges.

With those bits ready, let’s make this happen. I’ll be demonstrating with Nextcloud installed on Ubuntu Server 18.04.

Creating the log file

First we need to create a log file. We’ll have Nextcloud log to /var/log/nextcloud.log. Create that file with the command:

sudo touch /var/log/nextcloud.log

Once the file is created, give it the proper ownership with the command:

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

Now that the log file has the proper permissions, let’s configure Nextcloud to write to it.

Configure logging

Open the Nextcloud configuration file with the command:

sudo nano /var/www/html/nextcloud/config/config.php

In that file add the following (under ‘installed’ => true,):

“log_type” => “file”,
“logfile” => “/var/log/nextcloud.log”,
‘logfilemode’ => 0640,
“loglevel” => “0”,
“logdateformat” => “F d, Y H:i:s”,

Figure A illustrates how the configuration should look.


Figure A: The Nextcloud log configuration.

The log levels are:

  • 0: DEBUG: All activity; the most detailed logging.
  • 1: INFO: Activity such as user logins and file activities, plus warnings, errors, and fatal errors.
  • 2: WARN: Operations succeed, but with warnings of potential problems, plus errors and fatal errors.
  • 3: ERROR: An operation fails, but other services and operations continue, plus fatal errors.
  • 4: FATAL: The server stops.

Level 3 is the most often used. If you’re trying to solve a problem, and log level 3 isn’t giving you enough information, set it to 0.

Save and close that file. Restart Apache with the command:

sudo systemctl restart apache2

Check logging

Once you have Nextcloud configured for logging, you can use the built-in facility. Log into Nextcloud (with an admin account), click on the profile icon in the upper-right corner, and click Settings. In the Settings window, click Logging and you should see each log entry (Figure B).


Figure B: Nextcloud is now logging.

You can also change the log level from within the Nextcloud UI. Click the menu button to the right of Level and select the level of logging you want (Figure C).


Figure C: Selecting the log level from the Nextcloud GUI.

And that’s all it takes to enable logging for Nextcloud 16. Anyone who administers Nextcloud should do this as soon as the server is installed. With this in place, troubleshooting the platform will be so much easier.

Also see


Image: Jack Wallen

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button