Crate json_env_logger2
source · [−]Expand description
json_env_logger
is an extension of env_logger
crate providing JSON formatted logs.
The env_logger
is a crate that provides a way to declare what log levels are enabled for which modules \via a RUST_LOG
env variable. See its documentation for
syntax of declaring crate and module filtering options.
features
iso-timestamps
By default, a timestamp field called ts
is emitted with the current unix epic timestamp in seconds
You can replace this with IOS-8601 timestamps by enabling the iso-timestamps
feature. Note, this will add chrono
crate
to your dependency tree.
[dependencies]
json_env_logger = { version = "0.1", features = ["iso-timestamps"] }
backtrace
When registering a panic hook with panic_hook
by default backtraces are omitted. You can
annotate your error with then by enabling the backtrace
feature.
[dependencies]
json_env_logger = { version = "0.1", features = ["backtrace"] }
Functions
Yields the standard env_logger::Builder
configured to log in JSON format
Register configured json env logger implementation with log
crate.
Register a panic hook that serializes panic information as json
and logs via log::error
Register configured json env logger with log
crate