I am using python logging in django and I want to log errors to var/log folder. I am getting this error :
Unable to configure handler 'exception_logs': [Errno 2] No such file or directory: '/var/log/exceptions.log'
Below is my code snippet in settings.py
'handlers': {'exception_logs': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'simple',
'filename': '/var/log/exceptions.log',
},
},
First, make sure the file has been created
Then change the ownership of the file to the user that the server runs as. Assuming this is
www-data
:Alternatively, you could change the group owner of the file, and add the user to that group.