Drakulix / simplelog.rs

Simple Logging Facility for Rust
https://docs.rs/simplelog/
Apache License 2.0
433 stars 73 forks source link

How to update file path of the `WriteLogger` after I call `CombinedLogger::init`? #125

Closed yaoxin1995 closed 1 year ago

yaoxin1995 commented 1 year ago

After the global logger is set to WriteLogger with file path /a/b.

Is it possible to update the file path and let the logger log message to another file /a/c?

Drakulix commented 1 year ago

This is not possible with simplelog out of the box.

You could implement your own SharedLogger, that just wraps a WriteLogger inside an Arc<Mutex<_>>. Then you could exchange the logger in there at runtime to switch logging to a different file.

yaoxin1995 commented 1 year ago

many thanks, problem resolved