Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Create JSON Log Files In Rust With tracing

rust
```cargo
[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["json"] }
```
use tracing::{Level, event, instrument};

#[instrument]
fn main() {
    let format = tracing_subscriber::fmt::format()
      .json();
    tracing_subscriber::fmt()
      .event_format(format)
      .with_max_level(Level::DEBUG)
      .init();
  event!(Level::INFO, "This is the log message");
  event!(Level::DEBUG, "This is a debug message");
}
results start

This is what I'm using for my default logs to produce JSON output in Rust apps.

Footnotes And References