1

The tracing json subscriber gives the following stdout out of the box:

fn main() {
    tracing_subscriber::fmt()
        .json()
        .with_max_level(tracing::Level::DEBUG)
        .flatten_event(true)
        .init();

    tracing::debug!("This is a debug message");
}
{"timestamp":"2023-07-14T20:47:29.302872Z","level":"DEBUG","message":"This is a debug message","target":"publisher"}

How can I rename the field "level" to "severity"?

I tried to use the fmt::format::debug_fn but it doesn't seem to be compatible.

VBar
  • 13
  • 3

1 Answers1

0

The name "level" is hardcoded into tracing-subscriber, so I don't think you can change it without writing your own implementation of FormatEvent.

Filipe Rodrigues
  • 1,843
  • 2
  • 12
  • 21
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77