-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for New Relic log forwarding feature #222
Comments
It looks like The actual instrumentation that records the log messages appears to occur in NewRelic::Agent::Instrumentation::Logger where the an aggregator of log events gets called with a formatted log message. Potentially a custom appender could call this method (not sure if it's intended for public consumption). |
Anyone want to submit a Pull Request to add support for the above New Relic feature? Might be as simple as adding a new appender if the above NewRelic appender is not sufficient? |
If you add the New Relic appender and set the log level to something like SemanticLogger.add_appender(appender: :new_relic, level: :trace) Or if using Rails Semantic Logger, then in config.semantic_logger.add_appender(appender: :new_relic, level: :trace) |
I started migrating our logging to The Logging API is specified here: https://github.com/newrelic/newrelic-exporter-specs/tree/master/logging, the gem itself doesn't seem to have an API on the agent to push logs to NR without enabling forwarding, or at least so it seems to me. Other resources I consulted
I will be taking a stab at implementing a new appender tonight because I am not happy with the log forwarding facility offered by NewRelic at the moment |
Okay, I'm still digging a bit deeper here but I can see that the decorating formatter is not being applied for the standard logger. It seems the instrumentation from NewRelic and SemanticLogger step on each other here: logger = NewRelic::Agent::Logging::DecoratingLogger.new "log/application.log"
2022-11-10 19:04:20.481318 I [390011:5798320 (pry):6] NewRelic::Agent::Logging::DecoratingLogger -- hello
=> true |
Just tried |
Hey @texpert, not sure if you've seen my PR, but it might work for you. I've got quite busy with end of year work so haven't integrated this into our company's application yet. To fully use the new appender you need to enable NR log forwarding or the logs won't be dispatched, but I've raised this with the NR team already so their looking into it. If you do give the PR a go, please let me know on that thread if you run into any issues. |
Yay, it works after fixing a small typo in your PR, thank you! Impatiently waiting for the PR to get merged! |
Thank you for submitting a Pull Request, merged and will be released shortly in v4.13. |
Environment
Provide at least:
Expected Behavior
See the forwarded logs in the New Relic Triage->Logs dashboard, as the log forwarding support has been added in the 8.6.0 version of
newrelic_rpm
Actual Behavior
No logs are forwarded, and there is a text message stating that "the log forwarding is not enabled" in the New Relic Triage->Logs dashboard
When removing the SemanticLogger gems from the app, the logs are being successfully forwarded.
On this New Relic page SemanticLogger is listed as an incompatible gem - https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-ruby
The text was updated successfully, but these errors were encountered: