how can i change log timezone #1948
-
i find log time use utc time , i'm in utc+8 so I need cst time zone, but i dont'know how to change timezone. it seems can to change with_timer , tracing_subscriber::fmt()
.with_writer(mk_writer)
.with_max_level(Level::TRACE)
.with_timer(tracing_subscriber::fmt::time::time())
.init(); i find https://github.com/tokio-rs/tracing/blob/master/tracing-subscriber/src/fmt/time/time_crate.rs 110 line it seem wite like follow code ,but if i write this code, compile will says there is no use tracing_subscriber::fmt::{self, time::LocalTime};
use time::macros::format_description;
let timer = LocalTime::new(format_description!("[hour]:[minute]:[second]"));
tracing_subscriber::fmt()
.with_writer(mk_writer)
.with_max_level(Level::TRACE)
.with_timer(timer)
.init(); this is my cargo.toml [package]
name = "trace-example"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
axum = "0.4.5"
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.*"
tracing-subscriber = "0.3.8"
tracing-appender = "0.2"
tracing-log = "0.1.2"
log ="0.4.14"
tower-http = { version = "0.2.0", features = ["trace"] }
time = { version = "0.3", features = ["formatting", "macros"] } i don't know how to change timezone |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Sorry for the delay in responding; I missed this. You'll need to add the |
Beta Was this translation helpful? Give feedback.
Sorry for the delay in responding; I missed this. You'll need to add the
local-time
feature to thetracing-subscriber
dependency liketracing-subscriber = { version = "0.3", features = ["local-time"] }
. The documentation mentions this requirement.