#tracing-subscriber #structured-logging #json #logging-tracing #structured #logging

tracing-flat-json

A simple tracing-subscriber Layer emitting newline-delimited JSON

2 releases

0.1.1 Jan 26, 2026
0.1.0 Oct 26, 2025

#749 in Debugging

Download history 15952/week @ 2025-11-13 13703/week @ 2025-11-20 9781/week @ 2025-11-27 15368/week @ 2025-12-04 15524/week @ 2025-12-11 11057/week @ 2025-12-18 3596/week @ 2025-12-25 5493/week @ 2026-01-01 401/week @ 2026-01-08 285/week @ 2026-01-15 480/week @ 2026-01-22 533/week @ 2026-01-29 414/week @ 2026-02-05 752/week @ 2026-02-12 520/week @ 2026-02-19 811/week @ 2026-02-26

2,596 downloads per month

MIT license

48KB
796 lines

tracing-flat-json

A simple tracing_subscriber::Layer emitting newline-delimited JSON, with all event and span fields flattened onto the top level JSON object. Similar to combining the json-subscriber options with_flattened_event and with_top_level_flattened_span_list, without the caveats about duplicate fields noted in the documentation for those options.

Usage

use tracing_subscriber::prelude::*;

tracing_subscriber::Registry::default()
    .with(tracing_flat_json::FlatJsonLayer::new(std::io::stdout))
    .init();

Feature Flags

Output Format

Included:

  • timestamp (RFC3339 UTC)
  • level
  • trace_id (with feature tracing-opentelemetry)
  • code.file.path
  • code.line.number
  • event message
  • event fields, source code order
  • parent span fields, source code order, latest span first, root span last

Excluded:

  • span names
  • target
  • span_id
  • duplicate fields (only latest value for each field name)

Dependencies

~7–10MB
~106K SLoC