Setting Up a Logger to Output Logs to the Console in Django
Django
2022-09-12 12:21 (4 years ago)

settings/logging/console.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(name)s (%(process)d,%(thread)d) '
'%(levelname)s %(asctime)s '
'[%(module)s.%(funcName)s:%(lineno)d] '
' %(message)s'
},
'simple': {
'format': '%(name)s %(thread)d %(levelname)s '
'%(asctime)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
'level': 'INFO',
},
'django.request': {
'handlers': ['console'],
'level': 'INFO',
},
'django.db.backends': {
'handlers': ['console'],
'level': 'INFO',
'propagate': False,
},
'my-log': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
}
} Please rate this article (No signup or login required)
Currently unrated
Related posts
How to Fix Display Issues in Django Admin Inlines After Upgrading to 5.1
Return Login and Redirect Views by Hardcoding Social Account Provider in django-allauth (When Using AWS Cognito, etc.)
After Upgrading to Django 5 and Updating Dependencies, SSL: CERTIFICATE_VERIFY_FAILED Error Occurs When Sending Emails
The "first" and "second" Arguments of assertEqual in Django's Unit Tests are Actually "expected" and "actual"
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.