Skip to content

Commit

Permalink
Reduce spammy logging (#1915)
Browse files Browse the repository at this point in the history
* Reduce spammy logging

* Update submodule

* Azure sdk too
  • Loading branch information
trask authored Oct 15, 2021
1 parent e7b7aa6 commit c0d9719
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public void initLoggerLevels(LoggerContext loggerContext) {
updateLoggerLevel(loggerContext.getLogger("io.grpc.Context"));
updateLoggerLevel(loggerContext.getLogger("io.opentelemetry"));
updateLoggerLevel(loggerContext.getLogger("muzzleMatcher"));
updateLoggerLevel(
loggerContext.getLogger("com.azure.core.implementation.jackson.JacksonVersion"));
updateLoggerLevel(loggerContext.getLogger("com.microsoft.applicationinsights"));
updateLoggerLevel(loggerContext.getLogger(ROOT_LOGGER_NAME));
}
Expand All @@ -54,8 +56,7 @@ public void updateLoggerLevel(Logger logger) {
Level loggerLevel;
String name = logger.getName();
if (name.startsWith("reactor.netty") || name.startsWith("io.netty")) {
// never want to log reactor netty or netty at trace or debug, it's just way too verbose
loggerLevel = getAtLeastInfoLevel(level);
loggerLevel = getNettyLevel(level);
} else if (name.startsWith("io.grpc.Context")) {
// never want to log io.grpc.Context at trace or debug, as it logs confusing stack trace that
// looks like error but isn't
Expand All @@ -68,6 +69,10 @@ public void updateLoggerLevel(Logger logger) {
// muzzleMatcher logs at WARN level, so by default this is OFF, but enabled when DEBUG logging
// is enabled
loggerLevel = getMuzzleMatcherLevel(level);
} else if (name.startsWith("com.azure.core.implementation.jackson.JacksonVersion")) {
// need to suppress ERROR messages from this class since it cannot find the real jackson
// version due to shading
loggerLevel = Level.OFF;
} else if (name.startsWith("com.microsoft.applicationinsights")) {
loggerLevel = level;
} else {
Expand All @@ -81,9 +86,27 @@ private static Level getAtLeastInfoLevel(Level level) {
return getMaxLevel(level, Level.INFO);
}

private static Level getNettyLevel(Level level) {
if (level == Level.DEBUG || level == Level.TRACE) {
// never want to log reactor netty or netty at trace or debug, it's just way too verbose
return Level.INFO;
} else if (level == Level.INFO || level == Level.WARN) {
// suppress spammy reactor-netty WARN logs
return Level.ERROR;
} else {
return level;
}
}

private static Level getOpenTelemetryLevel(Level level) {
// bump DEBUG up to INFO, keep all others as-is
return level == Level.DEBUG ? Level.INFO : level;
if (level == Level.INFO) {
return Level.WARN;
} else if (level == Level.DEBUG) {
// use "trace" level to enable verbose debugging
return Level.INFO;
} else {
return level;
}
}

private static Level getOtherLibLevel(Level level) {
Expand Down

0 comments on commit c0d9719

Please sign in to comment.