Skip to content

Releases: Nebo15/logger_json

LoggerJSON is now a set of :logger formatters

14 May 01:02
8e855e0

Choose a tag to compare

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 and DataDog; 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 and LoggerJSON.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

  1. Update the package in mix.exs and then run mix deps.get:
++ {:logger_json, "~> 5.1"}
-- {:logger_json, "~> 6.0"}
  1. 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]}}
  1. 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

19 Oct 20:34

Choose a tag to compare

  • 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

18 Oct 23:42

Choose a tag to compare

  • OTEL integration for DataDog: now DataDog formatter would attempt to take otel_span_id and otel_trace_id metadata keys and write them to dd.span_id and dd.trace_id fields accordingly (#91) by @btkostner

5.1.0

18 Oct 23:40

Choose a tag to compare

  • 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

01 Mar 00:14

Choose a tag to compare

  • DataDog formatter is changed to leverage additional fields described by DataDog spec;
  • Minimum Elixir version is bumped to remove compilation warnings.

Default logger formatter is now not GSC specific

02 Apr 08:56

Choose a tag to compare

A new formatter that does not have Google Cloud specific fields is introduced and is used by default. (Thanks to @akoutmos.)

If you migrate from 3.X.X version and don't want logs structure to change please explicitly set Google Cloud formatter in your config.ex:

config :logger_json, :backend, formatter: LoggerJSON.Formatters.GoogleCloudLogger

3.1.2

30 Oct 15:00

Choose a tag to compare

Fixed a bug where RAM consumption can be very high due to a bug in Jason: michalmuskala/jason#94. It's recommended to upgrade to this version if you handle a large volume of logs.