Standard library logging

Learn how to send Ruby stdlib Logger output to Sentry as structured logs.

Sentry Structured Logs are enabled by default after the SDK is initialized. You can search, filter, and analyze logs from across your application in one place.

To capture logs from all loggers that use Ruby Logger, enable the :logger patch:

Copied
Sentry.init do |config|
  config.dsn = "___PUBLIC_DSN___"
  config.enabled_patches << :logger
end

Then all logs from Logger instances will be sent to Sentry, for example:

Copied
logger = Logger.new($stdout)

logger.debug("Hello from stdlib logger")
logger.info("Hello from stdlib logger")
logger.error("Hello from stdlib logger")

You can filter which logs are sent to Sentry using the std_lib_logger_filter configuration option.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").