Reputation: 46178
I'm running on a production server with WSGI & Apache.
I'm configuring a file logging for my Django project like:
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
#...
'logfile': {
'class': 'logging.handlers.WatchedFileHandler',
'filename': '/var/log/django/my_project.log'
},
},
'loggers': {
#...
'django': {
'handlers': ['logfile'],
'level': 'ERROR',
'propagate': False,
},
}
}
How can I know which user should own the file /var/log/django/my_project.log
?
Upvotes: 1
Views: 804
Reputation: 8027
You may run the WSGI process as a specific user, e.g.:
<VirtualHost *>
ServerName example.com
WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi
<Directory /var/www/yourapplication>
WSGIProcessGroup yourapplication
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Ideally to the one who owns /var/log/django
. (stat /var/log/django --printf=%U
)
Upvotes: 3