-
./logs/log file has this text |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The text in your log file appears mangled because it contains ANSI escape codes. When logging to the terminal, these escape codes configure formatting, such as changing the color of the text and italicizing, bolding, or underlining text. When written to a text file, however, these escape codes do nothing. By default, Change the subscriber construction to something like this, and your log file should look much nicer: tracing_subscriber::fmt()
.with_writer(non_blocking)
.with_ansi(false)
.init(); |
Beta Was this translation helpful? Give feedback.
The text in your log file appears mangled because it contains ANSI escape codes. When logging to the terminal, these escape codes configure formatting, such as changing the color of the text and italicizing, bolding, or underlining text. When written to a text file, however, these escape codes do nothing.
By default,
tracing_subscriber::fmt
assumes that logs will be written directly to the terminal, but you are instead configuring it to write to a log file. You can callwith_ansi(false)
when constructing the subscriber in order to disable the use of these escape codes.Change the subscriber construction to something like this, and your log file should look much nicer:
tracing_subscriber…