Produce JSON-formatted output from Rust's tracing crate
Channel: timClicks
Date: 2023-07-04

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-to-learn-rust

👋 Connect with Tim:
- Twitter: https://twitter.com/timClicks
- GitHub: https://github.com/timClicks
- Mastodon: https://mastodon.nz/@timClicks
- DEV: https://dev.to/timclicks/
- Patreon (extra learning materials) https://www.patreon.com/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_confirmation=1

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