Log file readability

tail -f /var/log/apache2/error.log

1 Like

Wow, its quite shocking to see the developersā€™ attitudes towards logging the lack of understanding and support given to those that need to interpret these logs.

For those that need help, hereā€™s what Iā€™ve found.

There is a useful log in (debian location) /var/www/html/data/nextcloud.log or /var/html/data/nextcloud/data/nextcloud.log

To make things more fun, the devs didnā€™t simply save logs. No no, they store the logs in JSON format. So youā€™ll get a really hard to read format of text returned if you tail the log file.

I get why they chose to do this. But pointing someone to a web based log reader, when the web interface is down, is just counter productive.

After some googling, I found that one can post process the file after tailing it. This makes it human readable.

tail -f /var/www/html/data/nextcloud.log | jq

If you get an error about jq being missing, just install it from the apt repo with sudo apt install jq

5 Likes

Logs being per default saved in data folder, or you can configure different location of it. Please check config file under your installation config/config.php.

'datadirectory' => '/var/www/nextcloud/data',

https://docs.nextcloud.com/server/19/admin_manual/configuration_server/config_sample_php_parameters.html#default-parameters

and

'logfile' => '/var/log/nextcloud.log',

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

jq is not part of many installations, try json_pp instead. E.g.:

tail -f /var/www/html/data/nextcloud.log | json_pp
1 Like

do you think itā€™s the right way addressing someone/your problems/your insights?

Remember we keep friendly while talking to others or about others. Plus: whereā€™s the additional benefit of what you wrote?

On a third point: you donā€™t need to crosspost stuff. --> Internal server error, where is the log?

Next time Iā€™d need to tell you to stay polite or such itā€™ll earn you an ā€œoffical warningā€.

Thanks for your attention.

3 Likes

Since it took me about two hours to format a lengthy excerpt of the error log from my installation for enhanced readability, redact sensitive information, and take advantage of the text formatting provided software by the behind the forum, I suspect that my workflow could be drastically improved. So it would be nice to have a way for users to effectively do all of this. Any suggestions?

tail -f /var/www/html/data/nextcloud.log | json_pp

Doesnā€™t work.

tail -f /var/www/html/data/nextcloud.log | jq

works just fine and is just an apt install away

2 Likes

I would not say that it does not work, on Ubuntu (that Iā€™m using) json_pp is part of perl module, that is usually installed per default, jq you need to install additionally. Of course both could be installed if not presented.

Yes, unfortunately jq is not installed and json_pp give this error:

cat data/nextcloud.log | json_pp
garbage after JSON object, at character offset 459 (before "ā€œreqIdā€:ā€œY2F3iauHi-gā€¦ā€) at /usr/bin/json_pp line 59.

So how can I view the log file?

apt install jq

@Sanook Without root access of course!

works for me - thanks

An arguably better solution than using just jq (which is great) is these two in combination: Is there any way to make the logfile more readable? - #6 by PancakeConnaisseur and Is there any way to make the logfile more readable? - #8 by meonkeys