This is a common practice
import logging
logger = logging.getLogger(__name__)
logger.info(f'Titan Proxy: {API_URL}')
and yet it was not showing up in the console 😡
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(levelname)s %(asctime)s %(name)s.%(funcName)s:%(lineno)s- %(message)s'
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'stream': sys.stdout,
'formatter': 'simple',
}
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': False,
},
'utils': {
'handlers': ['console'],
'level': 'INFO',
'propagate': True,
},
},
}
In the loggers
dictionary there are two entries:
django
will match any logger name that starts withdjango
django.server
django.request
utils
will match any logger name that starts withutils
utils.proxy
If your module does not show up, check the module name and then check the loggers
dictionary
There is no match Or it matches everything?
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
True
is the default, so it can be removed- The value reflects whether the message is passed to the parent logger