Documentation
DocumentationDiscussions
These docs are for v5.0. Click to read the latest docs for v2024.2.

Using 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.

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.