diff --git a/lib/datadog/tracing/contrib/rails/patcher.rb b/lib/datadog/tracing/contrib/rails/patcher.rb index 38a4c3f93a4..33eb03dc499 100644 --- a/lib/datadog/tracing/contrib/rails/patcher.rb +++ b/lib/datadog/tracing/contrib/rails/patcher.rb @@ -83,7 +83,7 @@ def add_logger(app) # if so, add proc that injects trace identifiers for tagged logging. logger = app.config.logger || ::Rails.logger - if (logger) \ + if logger \ && defined?(::ActiveSupport::TaggedLogging) \ && logger.is_a?(::ActiveSupport::TaggedLogging) @@ -91,7 +91,9 @@ def add_logger(app) should_warn = false end - Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger.class} is not supported") if should_warn + if should_warn + Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger.class} is not supported") + end end def patch_after_intialize