I am deploying a web service built on Django/Python at AWS using Elastic Beanstalk. I am using Django's logging feature to log website use and related data. While that worked fine with local testing, I an unable to get this to work with Beanstalk.
My code to log in settings.py
is:
# Django Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'spareguru.log',
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers':['file'],
'propagate': True,
'level':'DEBUG',
},
'customer': {
'handlers': ['file'],
'level': 'DEBUG',
},
}
}
The error I get while deploying to Beanstalk is:
ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/python/bundle/3/app/spareguru.log'
I also tried creating a file using .ebextensions
and making wsgi
the owner of that file but that didn't work either.
How can I fix this?