Search code examples
pythonjsonrenderingstdoutstructlog

setting up trees of renderers in structlog


How would I configure structlog such that all messages including above info would go to stdout using a KeyValueRenderer while all logging would also go to a file using a JSONRenderer?

note: I only want to use structlog, no standard library stuff


Solution

  • structlog doesn't do this out of the box, you'll need to write the required code yourself. structlog is built in a way to make this straightforward and it should be around a dozen of LoC.