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 am getting the previous logs from various modules but not the above log entry "this is an error message".
__name__
will outputusers.view
. So using solarissmoke's example above you would changemymodule
tousers.view
– Windup