slog-rs / slog

Structured, contextual, extensible, composable logging for Rust
https://slog.rs/
Apache License 2.0
1.58k stars 95 forks source link

[Question] Reconfiguring global logger? #278

Closed Geobert closed 3 years ago

Geobert commented 3 years ago

Hi, I have a global logger via slog_scope::set_global_logger and kept its guard. Now I want to reconfigure this logger. I tried to drop the guard and recreate another global logger, but I get a panic when dropping the guard… Is that normal? according to slog-rs/slog#169 it seems so but then…

how should I reconfigure the global logger?

dpc commented 3 years ago

Yeah, you're not supposed to drop that logger. You might want to use slog-atomic as a global logger, which should allow you to switch it atomically at any time.

Geobert commented 3 years ago

Thank you!