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, and - you want the log records from the third-party libraries processed by the same
structlogpipeline as your own log records.
In the most minimal setup, you only need change two things:
- Add the
l2sl.StdlibRecordParser()to the list ofprocessorsinstructlog.configure. - Call
l2sl.configure_stdlib_logging()after you are done configuringstructlog.
import l2sl
import structlog
structlog.configure(
processors=[
l2sl.StdlibRecordParser(),
...,
],
...,
)
l2sl.configure_stdlib_logging()Please have a look at the documentation.