Logging not working

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 21.0.4
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): nginx/1.18.0
PHP version (eg, 7.4): PHP 7.4.3

The issue you are facing:
Can anyone tell me why I am not seeing any log file in /var/log/nextcloud?

Is this the first time you’ve seen this error? (Y):

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

'log_type' => 'file',
'logfile' => '/var/log/nextcloud/error.log',
'loglevel' => 0,
'logdateformat' => 'F d, Y H:i:s',

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Hi @Jedi

Does Nextcloud have permission to write to /var/log/nextcloud/error.log?

Make sure it has the proper ownership with:

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

Oh and I forgot to write that you have to create the file first:

So first create the file…

touch /var/log/nextcloud/error.log

…and then set the ownership with the command from my first reply.

Hope that helps.

Yes that worked thank you but does this file just grow and grow and grow for ever?

Yes. But you can enable log rotation in the config.php…

https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html#logging

example:

log_rotate_size' => 100 * 1024 * 1024

And don’t forget to set www-data as the owner of the directory, otherwise Nextcloud cannot write new files…

chown www-data:www-data /var/log/nextcloud
1 Like

Thank you for this, very helpful.

On the page you linked to the log entries are in this format:

{
    "reqId":"TBsuA2uE86DiOD0S8f9j",
    "level":1,
    "time":"April 13, 2021 16:55:37",
    "remoteAddr":"192.168.56.1",
    "user":"admin",
    "app":"admin_audit",
    "method":"GET",
    "url":"/ocs/v1.php/cloud/users?disabled",
    "message":"Login successful: \"admin\"",
    "userAgent":"curl/7.68.0",
    "version":"21.0.1.1"
}

{
    "reqId":"ByeDVLuwkXKMfLpBgvxC",
    "level":2,
    "time":"April 14, 2021 09:03:29",
    "remoteAddr":"192.168.56.1",
    "user":"--",
    "app":"no app in context",
    "method":"POST",
    "url":"/login",
    "message":"Login failed: asdf (Remote IP: 192.168.56.1)",
    "userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36",
    "version":"21.0.1.1"
}

Is there a way to get the log entries in the log file in this format? It makes the log so much more readable.

One of the simplest ways but probably not a very efficient one is to install jq and pipe the log file to it.

sudo apt install jq

Then you could do something like…

sudo cat /var/log/nextcloud/error.log | jq

Or you could send your logs to systemd, and use journactl to look at your logs which I know has a “json-pretty” option. And there are many other ways and tools to manage filter and parse your logs, but I’m not an expert on this subject… I admit that I mostly use the Nextcloud WebUi to view the logs.

And someting eles comes to mind when I look at your OP…

You wanna porobaly set your loglevel to a value of “2”, unless you want to debug a specific problem. Otherwise, you generate way too many entries, which can make it harder to discovering real problems. In the worst case, it can also affect the performance of your server or shorten the life of the storage medium. Especially if you use something like a RaspbberyPi with a SD card or a USB key.