semantic_logger is a free, open source monitoring & observability project written in Ruby and released under Apache-2.0. It has 956 GitHub stars, 140 forks and 0 open issues, and was last pushed 3 days ago. On this registry it ranks #227 of 270 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

What is semantic_logger?

Semantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails that pushes log events onto an in-memory queue and writes them to one or more destinations from a separate background thread.

What it is

Semantic Logger is an Apache-2.0 licensed Ruby gem in the logging and observability space, distributed through RubyGems as semantic_logger and documented at logger.reidmorrison.com. It takes the place of an ordinary Ruby or Rails logger and changes two things about how logging works. First, it logs structured data rather than plain strings, so each entry can carry a payload hash, an exception with its backtrace, a duration, metrics, and tags, and that data survives all the way to the destination instead of being flattened into text. Second, it logs asynchronously: events go to an in-memory queue serviced by a background thread, so the application does not wait while log output is written.

The concrete problem it solves is log throughput and log searchability. Traditional logging makes the application wait while each log line is saved, which becomes a bottleneck at high volume. Semantic Logger decouples the caller from the write path so an application can log thousands of lines per second without slowing down. On the searchability side, because the payload is preserved, fields such as duration, table, or order_id stay queryable in the destination rather than being lost inside a formatted string. Within Rails, the specific thing it replaces is the Rails default logger, which the companion gem rails_semantic_logger swaps out automatically.

Key capabilities

  • Asynchronous delivery through an in-memory queue serviced by a dedicated thread, keeping log writes off the application's critical path.
  • Structured entries that carry an arbitrary payload hash, an exception, a duration, metrics, and tags, with that structure preserved to the destination.
  • Runtime configuration through SemanticLogger.default_level and SemanticLogger.add_appender, including the built-in formatter :color for screen output.
  • Block timing through measurements such as logger.measure_info, along with convenience calls like logger.info and logger.error that accept exception and context fields.
  • Out-of-the-box appenders for File, Screen, ElasticSearch, Graylog, BugSnag, NewRelic, Splunk, MongoDB, Honeybadger, Sentry, HTTP, TCP, UDP, Syslog, CloudWatch Logs, and OpenTelemetry.
  • Sentry support covering both the legacy sentry-raven gem and the modern sentry-ruby gem.
  • Interoperability options: any existing Ruby logger can be attached as another destination, and custom appenders can be written.
  • Optional per-appender dependencies, such as the bugsnag gem for the Bugsnag appender and the mongo gem family for MongoDB, which are not pulled in automatically.

Who uses it and how

  • Rails applications, which adopt it indirectly through rails_semantic_logger so the framework's default logger is replaced without manual wiring.
  • Background processing setups, including jobs running under the sister project Rocket Job, where job metrics are sent through Semantic Logger to dashboards.
  • Teams centralizing logs in search and analytics platforms, pairing the ElasticSearch appender with Kibana for dashboards and visualizations, or routing to Splunk, Graylog, or CloudWatch Logs.
  • Operations that need multiple simultaneous destinations, since one event can be fanned out to several appenders from the same queue-servicing thread.
  • Error-tracking workflows that forward exceptions and events to Sentry, BugSnag, or Honeybadger while still retaining local file or screen output.
  • High-volume services where write latency from the logging path is a measurable cost.

Getting started

Install the semantic_logger gem from RubyGems and configure it in code with SemanticLogger.default_level and SemanticLogger.add_appender. Rails users should install rails_semantic_logger instead of wiring Semantic Logger directly, because it replaces the default Rails logger automatically.

How it compares

The facts do not provide a list of paid products this project replaces, so the honest positioning is among the tools it names. It is the general-purpose base library, while rails_semantic_logger is the Rails integration layer that supersedes the framework's default logger, and Rocket Job is the sister batch system that fully supports it for background jobs. Every destination it writes to, from ElasticSearch and Splunk to Syslog and OpenTelemetry, is an endpoint it feeds rather than a product it substitutes.

When to use it — and when not to

A self-hoster must run whatever the chosen appenders point at, which can mean ElasticSearch and Kibana, MongoDB, Graylog, Splunk, CloudWatch Logs, or a Syslog and OpenTelemetry endpoint, and must add the optional gems each appender needs. Because writes happen on a background thread from an in-memory queue, the trade-off is that delivery depends on a running process rather than a synchronous write, so it suits services that value throughput over blocking guarantees. Teams outside Ruby and Rails should not pick it, and anyone expecting a batteries-included stack with no external destination to operate will find the initial setup heavier than a plain file logger.

project readme (upstream, from github) — read inline

Semantic Logger

Gem Version Build Status Downloads License

Semantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.

It differs from ordinary loggers in two important ways:

  1. It logs structured data, not just strings. Along with the text message, each log entry can carry a payload (any Hash), an exception, a duration, metrics, and tags. That data is preserved all the way to the destination, so it stays searchable instead of being flattened into text.
  2. It logs asynchronously. Log events are pushed onto an in-memory queue and written to their destinations by a separate background thread, so your application is not blocked while logs are written. Semantic Logger can log thousands of lines per second without slowing the application down.
require "semantic_logger"

SemanticLogger.default_level = :info
SemanticLogger.add_appender(io: $stdout, formatter: :color)

logger = SemanticLogger["MyApp"]

# A plain message, plus structured data that stays searchable
logger.info("Queried users table", duration: 54, result: :ok, table: "users")

# Log an exception with its full backtrace, plus context
logger.error("Failed to process order", exception: exception, order_id: 42)

# Measure and log how long a block takes to run
logger.measure_info("Reindexing users") { reindex_users }

When running Rails, use rails_semantic_logger instead, since it replaces the Rails default logger with Semantic Logger automatically.

Documentation

Start with the Introduction, then the Programmer's Guide.

Logging Destinations

Logging to the following destinations are all supported "out-of-the-box":

  • File
  • Screen
  • ElasticSearch. (Use with Kibana for Dashboards and Visualizations)
  • Graylog
  • BugSnag
  • NewRelic
  • Splunk
  • MongoDB
  • Honeybadger (exceptions and events)
  • Sentry (both with legacy sentry-raven and modern sentry-ruby gem)
  • HTTP
  • TCP
  • UDP
  • Syslog
  • CloudWatch Logs
  • OpenTelemetry
  • Add any existing Ruby logger as another destination.
  • Roll-your-own

Semantic Logger is capable of logging thousands of lines per second without slowing down the application. Traditional logging systems make the application wait while the log information is being saved. Semantic Logger avoids this slowdown by pushing log events to an in-memory queue that is serviced by a separate thread that only handles saving log information to multiple destinations / appenders.

Rails

When running Rails, use rails_semantic_logger instead of Semantic Logger directly since it will automatically replace the Rails default logger with Semantic Logger.

Rocket Job

Checkout the sister project Rocket Job: Ruby's missing batch system.

Fully supports Semantic Logger when running jobs in the background. Complete support for job metrics sent via Semantic Logger to your favorite dashboards.

Optional Dependencies

The following gems are only required when their corresponding appenders are being used, and are therefore not automatically included by this gem:

  • Bugsnag Appender: gem 'bugsnag'
  • MongoDB Appender: gem 'mongo' 1.9.2 or above
  • Honeybadger Appender: gem 'honeybadger'
  • HoneybadgerInsights Appender: gem 'honeybadger'
  • NewRelic Appender: gem 'newrelic_rpm'
  • NewRelicLogs Appender: gem 'newrelic_rpm'
  • Syslog Appender: gem 'syslog_protocol' 0.9.2 or above
  • Syslog Appender to a remote syslogng server over TCP or UDP: gem 'net_tcp_client'
  • Splunk Appender: gem 'splunk-sdk-ruby'
  • Elasticsearch Appender: gem 'elasticsearch'
  • OpenSearch Appender: gem 'opensearch-ruby'
  • Kafka Appender: gem 'ruby-kafka'
  • Legacy Sentry Appender: gem 'sentry-raven' (deprecated)
  • Sentry Appender: gem 'sentry-ruby'
  • OpenTelemetry Appender: gem 'opentelemetry-logs-sdk' (plus an exporter, e.g. 'opentelemetry-exporter-otlp-logs')

Upgrading

See the Upgrading Guide for instructions on upgrading between major versions.

Install

gem install semantic_logger

To configure a stand-alone application for Semantic Logger:

require 'semantic_logger'

# Set the global default log level
SemanticLogger.default_level = :trace

# Log to a file, and use the colorized formatter
SemanticLogger.add_appender(file_name: 'development.log', formatter: :color)

If running rails, see: Semantic Logger Rails

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to set up the project, run the tests, and an overview of the architecture, including a class diagram.

Author

Reid Morrison

Contributors

Versioning

This project uses Semantic Versioning.

Frequently asked questions

Is semantic_logger free to use?

semantic_logger is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does semantic_logger do?

Semantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.

What is semantic_logger written in?

semantic_logger is primarily written in Ruby. Its source is publicly available at https://github.com/reidmorrison/semantic_logger, and it has 956 GitHub stars.