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
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "local-time"] }
tracing-appender = "0.2.3"
Platform
Windows 10 Professional 22H2 19045.4894
Crates
tracing-subscriber
Description
I use two subscriber in axum server app, conosle layer & file layer.
And i disabled the ansi on file layer. In log file, color is diabled, the bold chars always there.
I tried this code:
// ## 1. registry tracing
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
// axum logs rejections from built-in extractors with the `axum::rejection`
// target, at `TRACE` level. `axum::rejection=trace` enables showing those events
format!(
"{}=debug,tower_http=debug,axum::rejection=trace",
env!("CARGO_CRATE_NAME")
)
.into()
});
// local time
let time_fmt = format_description::parse(
"[year]-[month padding:zero]-[day padding:zero] [hour]:[minute]:[second]",
)
.unwrap();
let time_offset = UtcOffset::current_local_offset().unwrap_or_else(|_| UtcOffset::UTC);
let timer: tracing_subscriber::fmt::time::OffsetTime<Vec<format_description::FormatItem<'_>>> =
tracing_subscriber::fmt::time::OffsetTime::new(time_offset, time_fmt);
// output to console
let console_format_layer = tracing_subscriber::fmt::layer()
.with_timer(timer.clone());
// output to file
let file_appender: rolling::RollingFileAppender = rolling::daily("logs", "server.log");
let (non_blocking_appender, _guard) = non_blocking(file_appender);
let file_layer = tracing_subscriber::fmt::layer()
.with_timer(timer.clone())
.with_writer(non_blocking_appender)
.with_ansi(false);
tracing_subscriber::registry()
.with(env_filter)
.with(console_format_layer)
.with(file_layer)
.init();
I expected to see this happen:
File server.log
0000-00-00 00:00:00 DEBUG http_request{method=GET matched_path="/user"}:get_user: my_server::handler::user: The request name is Tom
Instead, this happened:
File server.log
0000-00-00 00:00:00 DEBUG http_request{�[3mmethod�[0m�[2m=�[0mGET �[3mmatched_path�[0m�[2m=�[0m"/user"}:get_user: my_server::handler::user: The request name is Tom
I try to remove console layer, it's ok.
I try to disable ansi in console layer, it's ok.
-->
The text was updated successfully, but these errors were encountered:
Bug Report
Version
cargo.toml
Platform
Windows 10 Professional 22H2 19045.4894
Crates
tracing-subscriber
Description
I use two subscriber in axum server app, conosle layer & file layer.
And i disabled the ansi on file layer. In log file, color is diabled, the bold chars always there.
I tried this code:
I expected to see this happen:
File
server.log
Instead, this happened:
File
server.log
I try to remove console layer, it's ok.
I try to disable ansi in console layer, it's ok.
-->
The text was updated successfully, but these errors were encountered: