Standard library logging
Learn how to send Ruby stdlib Logger output to Sentry as structured logs.
Sentry Logs
Enable the Sentry Logs feature with config.enable_logs = true to unlock Sentry's full logging power. With Sentry Logs, you can search, filter, and analyze logs from across your entire application in one place.
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.
Note on structured logging
Ruby's stdlib logger does not support structured logging, that's why logs are sent to Sentry as plain messages with default attributes added automatically by the SDK.
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").
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").