Releases: Nebo15/logger_json
Releases · Nebo15/logger_json
6.2.1
What's Changed
- fix: check if Decimal is loaded in encoder by @davidjulien in #135
Full Changelog: 6.2.0...6.2.1
6.2.0
- Added :encoder_opts formatter option which allows passing any options down to
Jason
encoder, eg. if you want to format the output during development. Thanks to @anthonator; - Keep native DateTime, Date and Time structs when encoding them. This prevents those structs from being logged as maps. Thanks to @imricardoramos;
- Always return :ok even if nothing is logged fixes a bug when plug logger is configured not to return anything. Thanks to @adamu;
- A new
metadata
option is added which allows reading configuration from the default logger or any other place in the application environment. The downside of using it is that the application environment will be read on every logged message (since there is no way to init the state of:logger
formatter); - Replace μs with us because unicode is not always available in log aggregators. This value then also will be copied to appropriate provider-specific field. And separately copy it to an appropriate field depending on the formatter used. Thanks to @bvobart;
- Various docs, typos, and typespec fixes. Thanks to @dvic, @moxley.
- Fix Task/GenServer exits correctly in Google Cloud Logger formatter. Thanks @BrentWheeldon.
6.0.3
- Improve exception structure when logged using
Elastic
formatter; - Document usage of the
crash_reason
metadata key across formatters.
6.0.2
Bugs
- Do not crash when
metadata
is set tonil
, we will assume that is an empty list instead; Elastic
logger did not writemessage
and other keys when aconn
was present in the metadata.
6.0.1
- Fixed an issue where LoggerJSON will not compile in projects where Plus or Ecto are not added as a dependency
LoggerJSON is now a set of :logger formatters
This package has undergone a full rewrite and now it's just a set of Erlang's :logger
formatters. This means it has a much better integration with the ecosystem and the (outdated) custom Elixir's Logger
backend is removed.
The minimum supported Elixir version is now 1.15
.
Notable changes
- The logged structure for all providers has been updated to get up to date with the latest changes on those providers (eg. more metadata is logged for
GoogleCloud
andDataDog
;Basic
logs are cleaner); GoogleCloud
formatter now logs errors that are recognized by Google Cloud Error Reporting;- Now you can redact values in map/keyword/struct using a new
LoggerJSON.Redactors.RedactKeys
redactor; - Both
LoggerJSON.Plug
andLoggerJSON.Ecto
are now attached using Telemetry (old instrumentation callbacks are removed). Please keep in mind that using them in production is discouraged as it can be very expensive to log on every single request/database query; - We don't use
Jason.Encoder
protocol for structs anymore and just encode them as any other map. - A formatter for ElasticSearch, LogStash, FileBeat, and Kibana is added by @bvobart.
Upgrading from 5.X
- Update the package in
mix.exs
and then runmix deps.get
:
++ {:logger_json, "~> 5.1"}
-- {:logger_json, "~> 6.0"}
- Replace the legacy backend configuration and configure a default handler formatter instead:
--config :logger,
-- backends: [LoggerJSON]
--
--config :logger_json, :backend,
-- metadata: {:all_except, [:conn]},
-- json_encoder: Jason,
-- formatter: LoggerJSON.Formatters.GoogleCloudLogger
++ config :logger, :default_handler,
++ formatter: {LoggerJSON.Formatters.GoogleCloud, metadata: {:all_except, [:conn]}}
- If you are using Phoenix then remove the old usage of
LoggerJSON.Plug
in your endpoint:
--plug LoggerJSON.Plug
and attach the LoggerJSON.Plug
to the telemetry events in your application.ex
:
LoggerJSON.Plug.attach("logger-json-phoenix", [:phoenix, :endpoint, :stop], :info)
If you use Plug directly, replace the old usage of LoggerJSON.Plug
in your endpoint:
--plug LoggerJSON.Plug
++plug Plug.Telemetry, event_prefix: [:myapp, :plug]
and attach it using a telemetry in your application.ex
:
LoggerJSON.Plug.attach("logger-json-requests, [:myapp, :plug, :stop], :info)
Convert formatter_opts to be a keyword list
- A change has been made to use a keyword list for
formatter_opts
by default, but maps are supported to prevent breaking changed for DataDog logger (e363887)
Better OTEL integration for DataDog formatter
- OTEL integration for DataDog: now DataDog formatter would attempt to take
otel_span_id
andotel_trace_id
metadata keys and write them todd.span_id
anddd.trace_id
fields accordingly (#91) by @btkostner
5.1.0
- A phoenix router is added to Plug formatter (#90) by @btkostner
- A formatter now has a state and you can override how the host that will be written to DataDog (#87) by @btkostner
5.0.0
- DataDog formatter is changed to leverage additional fields described by DataDog spec;
- Minimum Elixir version is bumped to remove compilation warnings.