1👍
✅
You can work with a console
handler that works with the StreamHandler
instead:
LOGGING = {
# …,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers':['console'],
'propagate': True,
'level':'DEBUG',
},
'MYAPP': {
'handlers':['console'],
'level': 'DEBUG',
},
}
This will then write to the standard output channel (stdout
).
the file typically ends up being massive and I don’t use it.
You can also work with a RotatingFileHandler
[python-doc], this will prevent making huge files by only retaining the last n bytes:
LOGGING = {
# …,
'handlers': {
'rotate': {
'level': 'DEBUG',
'class': 'logging.RotatingFileHandler',
'filename': 'mysite.log',
'maxBytes': 10*1024*1024
},
},
'loggers': {
'django': {
'handlers':['rotate'],
'propagate': True,
'level':'DEBUG',
},
'MYAPP': {
'handlers':['rotate'],
'level': 'DEBUG',
},
}
Source:stackexchange.com