Skip to content

Commit

Permalink
Merge pull request #1068 from newrelic/log4j2-bug-fix
Browse files Browse the repository at this point in the history
Fix bug with log4j2 metrics not getting disabled
  • Loading branch information
jasonjkeller authored Nov 4, 2022
2 parents 8fe08c9 + 70da386 commit 66e53c7
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ public LoggerConfig_Instrumentation() {

protected void callAppenders(LogEvent event) {
// Do nothing if application_logging.enabled: false
// Do nothing if logger has parents and isAdditive is set to true to avoid duplicated counters and logs
if (isApplicationLoggingEnabled() && getParent() == null || !isAdditive()) {
if (isApplicationLoggingMetricsEnabled()) {
// Generate log level metrics
NewRelic.incrementCounter("Logging/lines");
NewRelic.incrementCounter("Logging/lines/" + event.getLevel().toString());
}
if (isApplicationLoggingEnabled()) {
// Do nothing if logger has parents and isAdditive is set to true to avoid duplicated counters and logs
if (getParent() == null || !isAdditive()) {
if (isApplicationLoggingMetricsEnabled()) {
// Generate log level metrics
NewRelic.incrementCounter("Logging/lines");
NewRelic.incrementCounter("Logging/lines/" + event.getLevel().toString());
}

if (isApplicationLoggingForwardingEnabled()) {
// Record and send LogEvent to New Relic
recordNewRelicLogEvent(event);
if (isApplicationLoggingForwardingEnabled()) {
// Record and send LogEvent to New Relic
recordNewRelicLogEvent(event);
}
}
}
Weaver.callOriginal();
Expand Down

0 comments on commit 66e53c7

Please sign in to comment.