l2sl funnels log records of third-party tools into your structlog pipeline. In addition, l2sl converts the text
based log records into a structured representation.
You need l2sl if
- you are using
structlogas the logging library in your application, - you depend on third-party libraries, e.g.
uvicornorhttpx, that use theloggingmodule from the standard library for logging, as they should, and - you want the log records from the third-party libraries processed by the same
structlogpipeline as your own log records.
Because that is the opposite of what you need if you have read until here.
structlog's standard library integration helps
integrating a structlog pipeline into an existing stdlib logging pipeline. l2sl let's you define the whole
pipeline in structlog without the need to ever touch stdlib logging including for any third-party libraries outside
of your control that use it.
The two setups are mutually exclusive: l2sl rejects a structlog configuration that is configured for stdlib
logging, since both want to own the output side of the pipeline.
In the most minimal setup, you only need to do add one thing to your logging setup, preferably after the
structlog.configure() call:
import l2sl
l2sl.configure_stdlib_log_forwarding()Please have a look at the documentation.