Hi all, I have a Rust program that runs in the background.
Now all logs were logged to stdout/stderr, but that program will run as a service, and I cannot capture the stdout/stderr to a file.
Sometimes the Rust program panicked, and I had no way to inspect the log (since everything was logger to stdout/stderr).
I guess the program was panicked, but I don't know how to capture the stack traceback and log them to a file (as normal log), so I can inspect them later.
Is there any logging library can log stack traceback when panicked or assertion failed?
Any logging library could, in theory. The functionality you're looking for is panic::set_hook.
As an off-the-shelf solution, tracing-panic provides a simple hook to emit a tracing error! when a panic occurs. It doesn't currently try to capture a backtrace, though.