Semantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.
See the codeSemantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.
It differs from ordinary loggers in two important ways:
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.
Start with the Introduction, then the Programmer's Guide.
docs/.Logging to the following destinations are all supported "out-of-the-box":
sentry-raven and modern sentry-ruby gem)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.
When running Rails, use rails_semantic_logger instead of Semantic Logger directly since it will automatically replace the Rails default logger with Semantic Logger.
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.
The following gems are only required when their corresponding appenders are being used, and are therefore not automatically included by this gem:
See the Upgrading Guide for instructions on upgrading between major versions.
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
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.
This project uses Semantic Versioning.
242 followers · starred Nov 2022
644 followers · starred Mar 2023
1,421 followers · starred Mar 2018
475 followers · starred Nov 2023
Semantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.
See the codeSemantic Logger is a high-performance, asynchronous structured logging framework for Ruby and Rails.
It differs from ordinary loggers in two important ways:
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.
Start with the Introduction, then the Programmer's Guide.
docs/.Logging to the following destinations are all supported "out-of-the-box":
sentry-raven and modern sentry-ruby gem)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.
When running Rails, use rails_semantic_logger instead of Semantic Logger directly since it will automatically replace the Rails default logger with Semantic Logger.
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.
The following gems are only required when their corresponding appenders are being used, and are therefore not automatically included by this gem:
See the Upgrading Guide for instructions on upgrading between major versions.
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
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.
This project uses Semantic Versioning.
242 followers · starred Nov 2022
644 followers · starred Mar 2023
1,421 followers · starred Mar 2018
475 followers · starred Nov 2023