From b9cadc09f8cfde965809ac2d47c6369678bea0c9 Mon Sep 17 00:00:00 2001 From: Tammy Baylis <96076570+tammy-baylis-swi@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:43:48 -0700 Subject: [PATCH] Update logs example re root logger (#4090) --- CHANGELOG.md | 1 + docs/examples/logs/example.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0ee94f3152..c69fee17385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added py.typed file to top-level module ([#4084](https://github.com/open-telemetry/opentelemetry-python/pull/4084)) - Drop Final annotation from Enum in semantic conventions ([#4085](https://github.com/open-telemetry/opentelemetry-python/pull/4085)) +- Update log export example to not use root logger ([#4090](https://github.com/open-telemetry/opentelemetry-python/pull/4090)) ## Version 1.26.0/0.47b0 (2024-07-25) diff --git a/docs/examples/logs/example.py b/docs/examples/logs/example.py index 2505aacea7a..ba471ea7e69 100644 --- a/docs/examples/logs/example.py +++ b/docs/examples/logs/example.py @@ -36,10 +36,9 @@ # Attach OTLP handler to root logger logging.getLogger().addHandler(handler) -# Log directly -logging.info("Jackdaws love my big sphinx of quartz.") - # Create different namespaced loggers +# It is recommended to not use the root logger with OTLP handler +# so telemetry is collected only for the application logger1 = logging.getLogger("myapp.area1") logger2 = logging.getLogger("myapp.area2")