diff --git a/instrumentation/apache-log4j-2/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig_Instrumentation.java b/instrumentation/apache-log4j-2/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig_Instrumentation.java index 4841bcb726..15f9df708c 100644 --- a/instrumentation/apache-log4j-2/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig_Instrumentation.java +++ b/instrumentation/apache-log4j-2/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig_Instrumentation.java @@ -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();