Tracing crate Logged file has unreadable and sufficient characters compared to STDOUT

When making a log to a file I got different data compared to the STDOUT log. There are some extra characters that I think represents some text formatting. Which text editor should be used for log file opening?

Below you can see the log from the file and from STDOUT.

LOG FILE
�[2mFeb 20 23:05:29.707�[0m �[32m INFO�[0m �[1;32mmac_rx::mac�[0m�[32m: �[32mWe are logging string., �[1;32mstring_log�[0m�[32m: Test String!�[0m �[2;3mat�[0m mac/mac_rx/src/lib.rs:751�[2;3m �[0m

STDOUT
Feb 20 23:05:56.948 INFO mac_rx::mac: We are logging string., string_log: Test String! at mac/mac_rx/src/lib.rs:751

2 Likes

Found the issue, configuration .with_ansi(false) needs to be added in tracing_subscriber::fmt().

It would be nice if it can be described in documentation

1 Like

Those weird characters are called ANSI escape sequence. Your terminal recognize it to make certain parts of your logs colored. If you cat the file instead of opening it in your editor you may see your normal logs with color.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.