Hi Uri,

On 12/01/2019 11.34, אורי wrote:
I'm trying to log debug & error messages to a file. But I receive this exception on the server:

ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/log/speedy_net_django.log'


The user running django does not have write access to '/var/log'. This is a good thing. You could give the user running django write access to '/var/log' or run django as another user, but I definitely wouldn't recommend that.

If I change the path to '/tmp/speedy_net_django.log' then it works.


That's because every user on the system has write access to '/tmp'.

How do I configure the server to write messages to '/var/log/speedy_net_django.log'? We use Ubuntu and nginx.


You could create a directory under '/var/log', eg. '/var/log/speedy_net' and give the user/group your running django as write access to that directory and write your logs to '/var/log/speedy_net/django.log'.

Our logging settings:
https://github.com/speedy-net/speedy-net/blob/staging/speedy/core/settings/base.py

By the way, are there friendlier ways to view logging messages than with text files?


Yes indeed. A much better solution would be to use the log system already available on the system (eg. syslog or journald).

That way you don't have to deal with rotating log files (not sure if djangos file logger handles that though) and permission problems.

Something like this might be useful:

https://www.simonkrueger.com/2015/05/27/logging-django-apps-to-syslog.html

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a872ce04-115d-ec66-de7a-1a0212308d31%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to