Posts

Showing posts from August, 2019

Django logging configuration

I wanted to configure logging in my django project. I had the following requirements: - All logs will be written to a file named app.log and the file will be rotated on each day - All error logs will be written to a file named app.error.log and the file will be rotated on each day - Logs will be written to console if DEBUG=True is set After experimenting with different configurations, I finally was able to achieve my goal using the following configuration. DJANGO_LOG_LEVEL = 'DEBUG' # need to change this value to enable/disable debug logs LOGGING = { 'version' : 1 , 'disable_existing_loggers' : False , 'formatters' : { 'simple' : { 'format' : '%(levelname)s %(asctime)s %(module)s %(funcName)s:%(lineno)d %(message)s' }, }, 'filters' : { 'require_debug_true' : { '()' : 'django.utils.log.RequireDebugTrue' , },