I have an app named main in my Django project. This app has a several management commands that I want to log, but nothing is showing up in stdout with the following configuration:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'log_to_stdout': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'stream': sys.stdout,
},
},
'loggers': {
'main': {
'handlers': ['log_to_stdout'],
'level': 'DEBUG',
'propagate': True,
}
}
}
What am I doing wrong? I’ve tried using my_project.main as well, but that didn’t work either. I’m using 1.3.0 final.
you need to namespace your logger. currently you are logging to the root logger, which isn’t caught by your handler, which is looking for
mainrather than
logging.debug("message"), you want