Django log file permissions with uwsgi

1.1k views Asked by At

I'm using Django with uwsgi. The process runs as www-data user which is also the owner of all log files (both for uwsgi & Django). When I use RotatingFileHandler for logging in Django, the new log files are created with the following permissions:

-rw-r--r-- 1 www-data www-data

I've added the the currently logged-in user (ubuntu) to www-data group but still don't have write permission to the above log files. As a result, I can't run python manage.py test.

How can I tell either (i) uwsgi or (ii) logging framework or (iii) file handler to create log files with permissions 0660 so that both ubuntu & www-data can read/write to the log files.

There's a caveat though, if I run manage.py test and logrotation happens at that moment, the new log file would be owned by ubuntu user and uwsgi will complain. I don't know if it's possible to fix this with altering the current user/group permission structure.

1

There are 1 answers

0
Árni St. Steinunnarson On

I think what you need is to implement your own subclass as demonstrated in this SO