Builds a :logger formatter that writes every log event as one line of JSON,
using LoggerJSON.Formatters.Basic with Zappi defaults.
Filebeat ships each line as its own Elasticsearch document, so plain-text output with struct inspections, multi-line SQL or stack traces fans out into many documents. One JSON line per event keeps it to one.
Requires {:logger_json, "~> 7.0"} in the app's deps. Call it from
config/runtime.exs:
config :logger, :default_handler,
formatter: Zexbox.Logging.JsonFormatter.config()It can't be called from config/config.exs or config/prod.exs: those are
evaluated before dependencies are compiled.
Summary
Functions
Returns the {formatter_module, config} tuple for config :logger, :default_handler, formatter: ....
The default metadata allow-list.
The default redactors.
Functions
Returns the {formatter_module, config} tuple for config :logger, :default_handler, formatter: ....
Takes any option LoggerJSON.Formatters.Basic.new/1 accepts. Options given
replace the defaults for that key:
:metadata- defaults todefault_metadata/0. Avoid:allin production. Trace and span IDs are always written as top-leveltraceandspanfields.:redactors- defaults todefault_redactors/0. Pass[]to disable. Redactors match exact key names and only apply to metadata and map or keyword messages, never to string messages.:encoder_opts- passed straight through.
Examples
iex> {module, _config} = Zexbox.Logging.JsonFormatter.config()
iex> module
LoggerJSON.Formatters.Basic
@spec default_metadata() :: [atom()]
The default metadata allow-list.
The default redactors.