Standard library logging

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

To enable logging for all loggers that use Ruby Logger you can enable the :logger patch:

Copied
Sentry.init do |config|
  config.dsn = "___PUBLIC_DSN___"
  config.enable_logs = true
  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").