-
-
Save farlandliu/3a97fc2887865e387c2872f334f3cfdf to your computer and use it in GitHub Desktop.
Django logging configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'root': { | |
'level': 'DEBUG', | |
'handlers': ['console', ], | |
}, | |
'filters': { | |
'require_debug_false': { | |
'()': 'django.utils.log.RequireDebugFalse' | |
} | |
}, | |
'formatters': { | |
'verbose': { | |
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' | |
}, | |
'simple': { | |
'format': '%(levelname)s: %(message)s' | |
}, | |
}, | |
'handlers': { | |
'null': { | |
'level': 'DEBUG', | |
'class': 'django.utils.log.NullHandler', | |
}, | |
'console': { | |
'level': 'DEBUG', | |
'class': 'logging.StreamHandler', | |
'formatter': 'verbose' | |
}, | |
'mail_admins': { | |
'level': 'ERROR', | |
'filters': ['require_debug_false', ], | |
'class': 'django.utils.log.AdminEmailHandler' | |
}, | |
'log': { | |
'level': 'DEBUG', | |
'class': 'logging.handlers.RotatingFileHandler', | |
'filename': 'logs/web.log', | |
'maxBytes': 1024*1024*5, # 5 MB | |
'backupCount': 5, | |
'formatter': 'verbose', | |
}, | |
'request_log': { | |
'level': 'DEBUG', | |
'class': 'logging.handlers.RotatingFileHandler', | |
'filename': 'logs/web-request.log', | |
'maxBytes': 1024*1024*5, # 5 MB | |
'backupCount': 5, | |
'formatter': 'verbose', | |
}, | |
}, | |
'loggers': { | |
'': { | |
'handlers': ['console', 'mail_admins', 'log', ], | |
'level': 'DEBUG', | |
}, | |
'django.db.backends': { | |
'handlers': ['console', ], | |
'level': 'ERROR', | |
'propagate': False, | |
}, | |
'django': { | |
'handlers': ['null', ], | |
'propagate': True, | |
'level': 'INFO', | |
}, | |
'django.request': { | |
'handlers': ['console', 'mail_admins', 'request_log', ], | |
'level': 'WARNING', | |
'propagate': False, | |
}, | |
'requests.packages.urllib3.connectionpool': { | |
'handlers': ['null', ], | |
'level': 'ERROR', | |
'propagate': False, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment