Created
April 11, 2019 15:51
-
-
Save raphaelyancey/bf8b53a2dbf675f9c99cf39f9e52c224 to your computer and use it in GitHub Desktop.
Example logging dictConfig for Python / Django and colorlog for colored logs
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, | |
'filters': { | |
}, | |
'formatters': { | |
'colored': { | |
'()': 'colorlog.ColoredFormatter', # colored output | |
# --> %(log_color)s is very important, that's what colors the line | |
'format': '%(log_color)s[%(levelname)s] %(asctime)s :: %(message)s' | |
}, | |
}, | |
'handlers': { | |
'console': { | |
'level': 'DEBUG', | |
'class': 'colorlog.StreamHandler', | |
'formatter': 'colored', | |
}, | |
'file': { | |
'level': 'DEBUG', | |
'class': 'logging.FileHandler', | |
'filename': '/var/log/app/django.log', | |
'formatter': 'colored', | |
}, | |
}, | |
'loggers': { | |
'': { | |
'handlers': ['console', 'file'], | |
'level': 'DEBUG', | |
'propagate': False, | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment