newrelic-ruby-agent icon indicating copy to clipboard operation
newrelic-ruby-agent copied to clipboard

Allow to replace agent logger for Rails

Open ojab opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Right now Railtie passes only config: in options and logger is initialized as NewRelic::Agent::AgentLogger.new(root, options.delete(:log)). So we have very rudimentary control of the logger output, either log to the file (default) or to STDOUT and the format is fixed.

Feature Description

Would be useful to pass logger somehow, so NewRelic log output could be completely controlled.

Describe Alternatives

   config.before_initialize do
      Rails.application.initializers.reject! { |initializer| initializer.name == 'newrelic_rpm.start_plugin' }

      NewRelic::Control.instance.init_plugin(config: Rails.configuration, log: SemanticLogger[NewRelic])
    end

works, but it's hacky and will break if NewRelic initialization changes. NewRelic::Agent#manual_start without removing the initializer doesn't work here, agent started two times.

Priority

Nice to Have, I guess?

ojab avatar Mar 18 '21 09:03 ojab

The same goes for env and other settings, I guess. We're running RAILS_ENV=production in staging and all the differences are in configuration, so either ENV['NEW_RELIC_ENV'] is needed (which is not ideal, because it's polluting ENV) or

NewRelic::Control.instance.init_plugin(config: Rails.configuration, env: Project.config.env)

ojab avatar Mar 18 '21 10:03 ojab

Great suggestion, @ojab -- I think there are multiple ways we can improve how logging can be configured, be agent, audit, or app. This is especially true with the emergence of Log Forwarders and our recently implemented feature to capture Logs in Context. A lot of different logging options have emerged over the years since the Agent's own logging facilities were designed and implemented.

Having said that, this is not a high priority item for us at the moment, but we welcome pull requests. If others are also looking for improved ability to manage any aspect of logging, chime in here to help us gauge interest that will influence our Ruby Instrumentation Roadmap

mwlang avatar Mar 18 '21 12:03 mwlang

This is not on our short-term roadmap but we will evaluate this for one of our quarterly feature packs.

elucus avatar Sep 21 '21 23:09 elucus

Closing as part of some issue pruning. We have not received subsequent related requests or PRs. We are certainly still open to hearing more from the community on this and anything else to help us determine priority.

fallwith avatar Jun 05 '23 22:06 fallwith