From c172022fdfb5ca3dbe95824a471df0ad48d65428 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 9 Oct 2023 11:05:51 +0200 Subject: [PATCH] docs: add recipe for stderr Fixes #551 --- docs/recipes.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/recipes.md b/docs/recipes.md index 2e4d6e04..b990ecc4 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -186,3 +186,12 @@ def manager(request_id: str): ``` See the [issue 425](https://github.com/hynek/structlog/issues/425) for a more complete example. + + +## Switching Console Output to Standard Error + +When using structlog without standard library integration and want the log output to go to standard error (*stderr*) instead of standard out (*stdout*), you can switch with a single line of configuration: + +```python +structlog.configure(logger_factory=structlog.PrintLoggerFactory(sys.stderr)) +```