How to change the logging level of a dependency?

Asked

Viewed 49 times

1

I’m trying to deal with the logging level of a dependency, where it’s showing INFO and I would not like her to show that level, because the information is not pertinent, in my case is the logging level of Junit 5.

Follow the dependency logging result when I run my code:

Sep 19, 2019 12:17:47 AM org.junit.platform.launcher.core.LauncherConfigurationParameters fromClasspathResource
INFO: Loading JUnit Platform configuration parameters from classpath resource [file:/E:/root/scalableapitesting/target/classes/junit-platform.properties].

Sum result is : 10
Subtraction result is : 5

Sep 19, 2019 12:17:47 AM org.junit.jupiter.engine.config.EnumConfigurationParameterConverter get
INFO: Using parallel execution mode 'SAME_THREAD' set via the 'junit.jupiter.execution.parallel.mode.default' configuration parameter.
Sep 19, 2019 12:17:47 AM org.junit.jupiter.engine.config.EnumConfigurationParameterConverter get
INFO: Using parallel execution mode 'CONCURRENT' set via the 'junit.jupiter.execution.parallel.mode.classes.default' configuration parameter.

Process finished with exit code 0

Every part of INFO, I would like to remove.

By searching, the logging api that Junit 5 uses:

Junit uses the Java Logging Apis in the java.util.logging package (a.k.a. JUL) to Emit warnings and debug information. Please refer to the Official Documentation of Logmanager for Configuration options.

I saw things about the logging.properties, log4j.properties but I still could not change the level, I believe that some configuration file will be possible to modify it.

Dependence on pom.xml that this generating the logging:

<dependency>
   <groupId>org.junit.jupiter</groupId>
   <artifactId>junit-jupiter-engine</artifactId>
   <version>5.5.2</version>
</dependency>
  • You can regulate the log level by packages, for example setting the level for the package org.junit.platform as INFO. Lamppost log4j.properties or logging.properties or slf4j ...

  • Well, after more research, I discovered that when using JUL, if you want to point to a different logging.properties, besides creating the Voce file you should point to the java.

1 answer

1


Well, the final solution was to "point" where this file has the properties I want in java, in which case it is in the Resources folder.

That is:

//Solução
String loggingPath = Main.class.getClassLoader().getResource("logging.properties").getFile();
System.setProperty("java.util.logging.config.file", loggingPath);

In the JUL documentation, the standard is to look at the level of JRE (which I found somewhat strange) because changing to the X application can cause effect on the Y application.

On changing system properties, as I am running each jar in isolated containers it will not be a problem to change system property.

In my configuration file (which already existed), the line that does what I want is this:

org.junit.level=WARNING

Browser other questions tagged

You are not signed in. Login or sign up in order to post.