ExSeq

ExSeq is an Elixir Logger backend for sending logs to Seq using the Compact Log Event Format (CLEF).

Features

Installation

Add ex_seq to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_seq, "~> 0.1.0"}
  ]
end

Then run:

mix deps.get

Configuration

In your config.exs, set up the logger to use ExSeq:

config :logger,
  backends: [:console, ExSeq],
  level: :info

config :logger, ExSeq,
  level: :info,
  seq_url: "http://localhost:5341/ingest/clef",
  api_key: "YOUR_SEQ_API_KEY",

You can also tune the flush interval and batch size:

  flush_interval: 5,  # Flush every 5 seconds
  batch_size: 100

How It Works

  1. ExSeq implements the :gen_event behavior, which the Elixir Logger uses for backends.
  2. When a log event arrives, ExSeq checks if its level is >= the configured minimum. If so, it converts the event to a CLEFEvent struct.
  3. The event is then sent asynchronously to the ExSeq.Flusher GenServer for batching and sending to Seq.

Usage

After adding ExSeq to your logger backends and setting your :level, just log as usual in Elixir:

Logger.debug("This is a debug log")  # Will be filtered out if :level >= :info
Logger.info("An info-level message")
Logger.warn("A warning")
Logger.error("An error occurred!")

Each message you log is converted into a CLEF event and sent to Seq. If you’ve configured your seq_url and (optionally) an api_key correctly, you should see your events in the Seq UI under the configured ingestion endpoint.

Example

defmodule MyApp do
  require Logger

  def run do
    Logger.info("Starting application", foo: "bar")
    # ...
    Logger.error("Oops, something went wrong!", user_id: 123)
  end
end

You can then start your application (e.g. via iex -S mix) and see the logs in Seq if everything is configured properly.

Notes

Contributing

  1. Fork the repository.
  2. Create a feature branch.
  3. Make your changes and write tests if necessary.
  4. Submit a Pull Request.

License

This project is MIT Licensed.