ExSeq is an Elixir Logger backend for sending logs to Seq using the Compact Log Event Format (CLEF).
- Minimal configuration required
- Converts Elixir log messages and metadata into CLEF events
- Sends events asynchronously through a GenServer
- Filters log messages based on minimum log level
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
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",
-
level
sets the minimum level for sending to Seq. Levels below this are ignored. -
seq_url
is the endpoint of your Seq server. -
api_key
is your Seq API key if required for authentication (optional if Seq isn’t secured).
You can also tune the flush interval and batch size:
flush_interval: 5, # Flush every 5 seconds
batch_size: 100
-
ExSeq
implements the:gen_event
behavior, which the ElixirLogger
uses for backends. - When a log event arrives,
ExSeq
checks if its level is >= the configured minimum. If so, it converts the event to a CLEFEvent struct. - The event is then sent asynchronously to the
ExSeq.Flusher
GenServer for batching and sending to Seq.
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.
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.
-
ExSeq
uses a custom minimal:gen_server
(theFlusher
) to batch events and send them in the background. - Timestamps are pulled from the Elixir logger metadata if present, or from the default Erlang timestamp.
- The log level is converted from Elixir’s levels (
:debug
,:info
,:warn
,:error
) to CLEF’s equivalent (Debug
,Information
,Warning
,Error
) viaCLEFLevel.elixir_to_clef_level/1
.
- Fork the repository.
- Create a feature branch.
- Make your changes and write tests if necessary.
- Submit a Pull Request.
This project is MIT Licensed.