Skip to content

Default structured logging to off and require explicit opt-in #3101

Description

@sentry-junior

Rails structured logging automatically turns Rails ActiveRecord and ActionController events into Sentry logs. That makes it automatic logging instrumentation, so starting with sentry-rails 7.1.0 it will be off by default, like the rest of logs and metrics. The interpretation behind that behavior was that adding sentry-rails counted as the logging opt-in, analogous to adding a dedicated logging integration. But in that case it was too ambiguous; this is a corrective follow-up.

We're sorry for the disruption of changing a default within 7.x. We chose to make the change now instead of waiting for 8.0, so that everyone adopting logs gets the same, predictable behavior from the start.

Make Rails structured logging opt-in

Users who want Rails structured logs should enable them explicitly:

Sentry.init do |config|
  config.rails.structured_logging.enabled = true
end
Implementation notes

Background

  • Before 7.0, config.rails.structured_logging.enabled followed the global enable_logs option. feat!: Remove enable_logs #3053 removed enable_logs in 7.0 and set the Rails default to true.
  • 7.1.0 makes it opt-in: an unset option means off, and sentry-rails logs a warning at boot until the option is set explicitly. Both the warning and the "unset" state are removed in 8.0.
  • Sentry.logger.* stays available regardless of this setting. No global enable_logs gate and no double opt-in.

SDK (sentry-rails 7.1.0)

  • Default structured_logging.enabled to true or nil (unset), treated as off
  • Changelog entry via the PR description
  • Changelog entry explaining new default

Docs (sentry-docs, released with 7.1.0)

  • Rails quickstart snippet (platform-includes/getting-started-config/ruby.rails.mdx): add config.rails.structured_logging.enabled = true
  • Rails logs setup (platform-includes/logs/setup/ruby.rails.mdx): opt-in wording and snippet
  • Rails logs options (platform-includes/logs/options/ruby.rails.mdx): opt-in wording, enable/disable sections
  • Rails logs page (docs/platforms/ruby/guides/rails/logs/index.mdx): troubleshooting and requirements ("opt-in since 7.1.0")

Release and follow-up

  • Pin this issue when 7.1.0 is released
  • 7.2: remove the post_install_message

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions