I am looking desperately for a solution for the following problem: For a project, I need multiple independent loggers let's say one for logging readable progress for the user to console (stderr) and one for collecting some stats into a json output file. I am using structlog and my example below shows the problem
import structlog
logger1 = structlog.get_logger()
logger1.info('make something that needs to be logged', x=1, y=2, z='abc')
logger2 = structlog.get_logger()
structlog.configure(processors=[structlog.processors.JSONRenderer()])
logger2.info('structured_output', a=[1, 2, 3], b={'a': 1})
logger1.info('now this one is also json but it shouldn\'t')
gives the output
2022-06-08 08:30.34 [info ] make something that needs to be logged x=1 y=2 z=abc
{"a": [1, 2, 3], "b": {"a": 1}, "event": "structured_output"}
{"event": "now this one is also json but it shouldn't"}
logger1 works fine until I apply the configuration for json rendering.
What I would like to see is
2022-06-08 08:30.34 [info ] make something that needs to be logged x=1 y=2 z=abc
{"a": [1, 2, 3], "b": {"a": 1}, "event": "structured_output"}
2022-06-08 08:39.41 [info ] still no json output, great!
How can I keep both loggers separate so that the configuration for logger1 is unchanged?
Thanks! Max