/ejsonlog

A drop-in logger formatter for Erlang that outputs messages as line delimited JSON.

Primary LanguageErlangApache License 2.0Apache-2.0

ejsonlog

A drop-in logger formatter for Erlang that outputs messages as line delimited JSON.

Overview

This formatter is heavily inspired by flatlog, but it is meant to produce JSON logs.

It does not impose a specific "Erlang term to JSON" formatter and can be configured to use the one you prefer.

Just like flatlog, this formatter should not be added as a dependency in individual libraries.

Configuration

For configuration instructions, generate and read the Edoc documentation.

Caveats

Due to Erlang's logger design, log messages are fully generated by the processes that call logging commands, before they are sent to a backend e.g. for writing them on a file.

As a result, if ejsonlog is used together with Loki and promtail, the time field should not be used to overwrite the default timestamp generated by promtail, as log lines may end up out-of-order in files.

Build

$ rebar3 compile

Acknowledgements

This project was created as part of Erlang Solutions' Hackathon on 2021-03-23.