Below snippet of logging system works fine with django application with logs following the required formate, but fails in a celery application
logging.config.dictConfig(
{
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"json": {
"format": "%(name)s %(module)s %(filename)s %(funcName)s %(lineno)d %(message)s ",
"class": "pythonjsonlogger.jsonlogger.JsonFormatter",
}
},
"handlers": {"json": {"class": "logging.StreamHandler", "formatter": "json"}},
"loggers": {
"": {"handlers": ["json"], "level": logging.DEBUG} # Set log level info
},
}
)
configure(
context_class=threadlocal.wrap_dict(dict),
logger_factory=stdlib.LoggerFactory(),
wrapper_class=stdlib.BoundLogger,
processors=[
stdlib.filter_by_level,
stdlib.add_logger_name,
stdlib.add_log_level,
stdlib.PositionalArgumentsFormatter(),
processors.TimeStamper(fmt="iso"),
processors.StackInfoRenderer(),
processors.format_exc_info,
processors.UnicodeDecoder(),
stdlib.render_to_log_kwargs,
],
)
log = structlog.getLogger(__name__)
log.info('Log content', input='some input')
This fails in the case of my celery standalone application.Basically the pythonjsonlogger configuration is not taking an effect. The logs are coming with default logger settings. Am I missing something. Any help is appreciated, Thanks
loggingconfiguration, your problem is unrelated tostructlogand you're unnecessarily limiting the audience of your question. Maybe stackoverflow.com/questions/48289809/… can help?