emabee / flexi_logger

A flexible logger for rust programs that can write to stderr, stdout, and/or to log files
Apache License 2.0
307 stars 50 forks source link

Different logger instances per thread? #151

Closed smabie closed 11 months ago

smabie commented 11 months ago

Hi, I would like to have a different logger instance used per thread, is this possible?

Right now using the multiple writers functionality to simulate this functionality, but it's quite suboptimal.

emabee commented 11 months ago

That's indeed not directly supported.

An alternative solution could be using a line format like with_thread, which adds the thread name to the log line header, and then isolating a concrete thread by grepping for T[<thread_name>] etc.