-
-
Save dalmosantos/2a43e252122cbb4f9a7b5c093d5587e1 to your computer and use it in GitHub Desktop.
Python logging configuration example
This file contains hidden or 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
import logging | |
import logging.config | |
logging.dictConfig({ | |
'version': 1, | |
'disable_existing_loggers': False, | |
"formatters": { | |
"standard": { | |
"format": '%(asctime)s %(name)s %(levelname)s %(message)s' | |
} | |
}, | |
'handlers': { | |
'file': { | |
'level': 'DEBUG', | |
'filename': 'activity.log', | |
'formatter': 'standard', | |
"class": "logging.handlers.RotatingFileHandler", | |
"maxBytes": 1048576, # 1MB | |
"backupCount": 0 # keep all the files | |
}, | |
}, | |
'loggers': { | |
'django': { | |
'handlers': ['file'], | |
'level': 'INFO', | |
'propagate': True | |
}, | |
'backend': { | |
'handlers': ['file'], | |
'level': 'DEBUG', | |
} | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment