Skip to content

tracing-appender mangles text #2589

Closed Answered by hawkw
SephVelut asked this question in Q&A
Discussion options

You must be logged in to vote

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 call with_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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hawkw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants