tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.52k stars 725 forks source link

tracing-subscriber: programmatically opt out of setting a global logger even when `tracing-log` is enabled #3074

Open lcmgh opened 2 months ago

lcmgh commented 2 months ago

If one wants to opt-out of letting tracing-subscriber init. a global logger one has to disable the feature flag tracing-log.

There are setups when an app wants to decide by config whether a global logger should be set by tracing-subscriber. This can currently not be done because the setting must be configured on compile time.

Example scenarios that all should be configurable on runtime:

To support both cases tracing-log must be set which then throws an error for the first scenario.

sdtnjung commented 2 months ago

Workaround: Use tracing-subscriber with default-features = false and only initialize the log_tracer when really needed.