Produce JSON-formatted output from Rust's tracing crate

Опубликовано: 02 Март 2026
на канале: timClicks
3,722
109

Logging is useful, but log messages that are easily parsed are even more useful. This example shows how to use Rust, Axum web framework, Tokio and Tracing.

Here is the relevant section of my project's Cargo.toml file:

[dependencies]
axum = { version = "0.6.18", features = ["tracing"] }
serde_json = "1"
tokio = { version = "1.29", features = ["full"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }


📚 Resources:
https://docs.rs/tracing
https://docs.rs/tracing-subscriber





🦀 Rust resources:
Tim's tutorial videos https://timclicks.dev
Rust Documentation: https://doc.rust-lang.org/book/
Rust Playground: https://play.rust-lang.org/
Rust in Action (Tim's book!) https://mng.bz/4MlD
How to Learn Rust (online course!) https://learning.accelerant.dev/how-t...

👋 Connect with Tim:
Twitter:   / timclicks  
GitHub: https://github.com/timClicks
Mastodon: https://mastodon.nz/@timClicks
DEV: https://dev.to/timclicks/
Patreon (extra learning materials)   / timclicks  


🔔 Subscribe to the channel and click the bell icon to stay updated with the latest videos and live streams from timClicks: https://www.youtube.com/timClicks?sub...

👍 Like this video if you found it helpful, and share it with your friends who are also interested in Rust programming.