jettyRun seems to run with java util log system set to DEBUG level


(Mike Gillam) #1

After converting our project to use gradle (which is largely fantastic btw), we noticed that our app start up time through a jettyRun task seemed to be noticable slower. After a bit of debugging we noticed the following code in the class org.gradle.logging.internal.JavaUtilLoggingConfigurer:

public class JavaUtilLoggingConfigurer implements LoggingConfigurer {
    private boolean configured;
      public void configure(LogLevel logLevel) {
        if (configured) {
            return;
        }
          LogManager.getLogManager().reset();
        SLF4JBridgeHandler.install();
        Logger.getLogger("").setLevel(java.util.logging.Level.FINE);
 // <------ *** INTERESTRING LINE ***
        configured = true;
    }
}

Seems like this line forces the global logger (and hence all non-explicitly set loggers) to run at DEBUG level.

So, I added the following snippet to my jettyRun task:

doFirst {
    println("Resetting JDK log level to INFO...")
    java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.INFO);
  }

and this seems to fix the issue.

Anyway, is the fix appropriate, or am I missing a more elegant way of controlling log levels during a jetty run?

Thanks in advance for any help… Mike.