You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tracing_appender::non_blocking function returns a non-blocking writer and a drop guard which flushes the writer and shuts it down when dropped. This is intended to be used to ensure the background thread terminates cleanly when the application exits, even in the event of a panic.
However, in order for this to work, the returned guard value has to be held in the program's main function, since dropping it earlier will shut down the writer. In this case, your setup_logs function drops the returned guard as soon as it exits, so the worker thread is shut down immediately.
Try changing your code to something like this, and ensuring that you hold onto the returned guard in your main function:
Bug Report
Version
Platform
Linux jack-pc 5.10.53-1-MANJARO #1 SMP PREEMPT Mon Jul 26 07:18:28 UTC 2021 x86_64 GNU/Linux
Crates
tracing-appender v0.1.2
Description
One way to structure the description:
tracing-appender creates the specified log file, but does not write anything into it
I tried this code:
I expected to see this happen: the log file contains log
Instead, this happened: the log file exists but is empty
The text was updated successfully, but these errors were encountered: