I am fairly new in backend development. I was trying to write some log with Django rest framework. I set up the WSGI mode and the 000-default.conf
file is
<VirtualHost *:80>
ServerAdmin user@gmail.com
DocumentRoot /home/ubuntu/myproject_backend/myproject
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/ubuntu/myproject_backend/myproject/static
<Directory /home/ubuntu/myproject_backend/myproject/static>
Require all granted
</Directory>
<Directory /home/ubuntu/myproject_backend/myproject>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-path=/home/ubuntu/myproject_backend/myproject python-home=/home/ubuntu/myproject_backend/env
WSGIProcessGroup myproject
WSGIScriptAlias / /home/ubuntu/myproject_backend/myproject/myproject/wsgi.py
WSGIPassAuthorization On
</VirtualHost>
I added the LOGGING
in the setting.py
LOGGING = {
'version': 1,
# Version of logging
'disable_existing_loggers': False,
#disable logging
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'my_log.log',
}
},
'loggers': {
'django': {
'handlers': ['file'],
'level': env("LOG_LEVEL"),
'propagate': True,
},
},
}
I tried with a simple warning log
logging.warning("Logging Tutorials")
Now the log is working when I was testing locally with the runserver
command. However, when I pushed the code to the server it's getting permission denied writing the error.log
file.
PermissionError: [Errno 13] Permission denied
I was wondering how do I give the permission and which user? the server is a ubuntu OS.
I know there are a few posts about this issue. However, I could not figure out what exactly do I have to do. Thanks in advance.