Documentation
DocumentationDiscussions
Documentation
These docs are for v2021.2. Click to read the latest docs for v2024.3.

Ruby

For Ruby applications, in addition to raw HTTP ingestion, the semlogr gem and its Seq sink can be used to send structured log events efficiently to Seq.

📘

In addition to the excellent support provided by semlogr, Seq can alternatively accept events from Ruby applications via UDP in the GELF format. This must be explicitly enabled using the instructions in Using GELF. See your preferred logging library's documentation for details of how to configure GELF logging.

Overview

Semlogr and its Seq sink can be installed from RubyGems:

gem install semlogr
gem install semlogr-sinks-seq

The logger configuration supports write_to :seq:

require 'semlogr'
require 'semlogr/sinks/seq'

Semlogr.logger = Semlogr.create_logger do |c|
  c.log_at :info

  c.write_to :seq, server_url: 'http://localhost:5341', api_key: 'xxxxxxxx'
end

The server_url should be the base URL of your Seq installation. An optional api_key is accepted.

Log events are written using message templates with named parameters:

Semlogr.info('Hello, {name}!', name: 'World')
Semlogr.error('API could not be contacted', error: err)

Events are sent to Seq asynchronously in batches.

More usage samples can be found in the Semlogr repository.