Reduce log output of third party libs

Fixes #1064
This commit is contained in:
AsamK 2023-05-21 11:49:26 +02:00
parent 8a0005d900
commit 8c1b5d54f7

View file

@ -37,7 +37,7 @@ public class LogConfigurator extends ContextAwareBase implements Configurator {
public ExecutionStatus configure(LoggerContext lc) { public ExecutionStatus configure(LoggerContext lc) {
final var rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME); final var rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
final var defaultLevel = verboseLevel > 1 ? Level.ALL : verboseLevel > 0 ? Level.DEBUG : Level.INFO; final var defaultLevel = verboseLevel > 1 ? Level.ALL : verboseLevel > 0 ? Level.INFO : Level.WARN;
rootLogger.setLevel(defaultLevel); rootLogger.setLevel(defaultLevel);
final var consoleLayout = verboseLevel == 0 || logFile != null final var consoleLayout = verboseLevel == 0 || logFile != null
@ -46,18 +46,15 @@ public class LogConfigurator extends ContextAwareBase implements Configurator {
final var consoleAppender = createLoggingConsoleAppender(lc, createLayoutWrappingEncoder(consoleLayout)); final var consoleAppender = createLoggingConsoleAppender(lc, createLayoutWrappingEncoder(consoleLayout));
rootLogger.addAppender(consoleAppender); rootLogger.addAppender(consoleAppender);
lc.getLogger("com.zaxxer.hikari") lc.getLogger("org.asamk").setLevel(verboseLevel > 1 ? Level.ALL : verboseLevel > 0 ? Level.DEBUG : Level.INFO);
.setLevel(verboseLevel > 1 ? Level.ALL : verboseLevel > 0 ? Level.INFO : Level.WARN);
if (logFile != null) { if (logFile != null) {
consoleAppender.addFilter(new Filter<>() { consoleAppender.addFilter(new Filter<>() {
@Override @Override
public FilterReply decide(final ILoggingEvent event) { public FilterReply decide(final ILoggingEvent event) {
return event.getLevel().isGreaterOrEqual(Level.INFO) return event.getLevel().isGreaterOrEqual(Level.WARN) || (
&& !"LibSignal".equals(event.getLoggerName()) event.getLevel().isGreaterOrEqual(Level.INFO) && event.getLoggerName()
&& ( .startsWith("org.asamk")
event.getLevel().isGreaterOrEqual(Level.WARN) || !event.getLoggerName()
.startsWith("com.zaxxer.hikari")
) )
? FilterReply.NEUTRAL : FilterReply.DENY; ? FilterReply.NEUTRAL : FilterReply.DENY;