This is my settings module:
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'file': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'filename': '/django-python/django/testapp/testapp.log', }, }, 'loggers': { 'django': { 'handlers': ['file'], 'level': 'DEBUG', 'propagate': True, }, }, }
and this is my code in a view file:
import logging logger = logging.getLogger(__name__) logger.info("this is an error message!!")
I get previous logs from different modules, but in this case, the log is "this error message."
django django-logging
Teja reddy
source share