Hi.
We ran into a situation where our test extension does this:
static {
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
}
Which sets up the Java Util Logging to use our own logger.
Except JUnit initialises Java Util Logging before our extension is loaded, via its LoggerFactory.DelegatingLogger, which forbids us from setting up our own log manager, because it can only be set before anybody tries to access it.
Is there a way for an extension point to get called before creating a LoggerFactory.DelegatingLogger?
If not, is there a way to point JUnit to our own implementation of its Logger? I see the interface you created, but I don't understand if it's possible to point JUnit to anything else than a JUL delegating logger?
Thanks for your help!
Is there a way for an extension point to get called before creating a
LoggerFactory.DelegatingLogger?
No, that's not possible. Extensions get initialized after the core of the JUnit Platform.
If not, is there a way to point JUnit to our own implementation of its
Logger? I see the interface you created, but I don't understand if it's possible to point JUnit to anything else than a JUL delegating logger?
You can configure your own LogManager via a JVM system property prior to starting the JUnit Platform.
For example -- although it's commented out -- the following shows how one can achieve this for the test task in a Gradle build.
You can achieve the same in a Maven build or for a particular test run in an IDE. Most IDEs have some sort of "run configuration" that can configure JVM system properties.
In light of that, I am closing this issue.
Hope this answers your questions!
You can achieve the same in a Maven build or for a particular test run in an IDE. Most IDEs have some sort of "run configuration" that can configure JVM system properties.
Well, they do, but that means you can't just "right click > run as test" without having to go create a configuration, which is a really bad user experience.
Is there really no way to get an extension point especially for logging?
Most helpful comment
Well, they do, but that means you can't just "right click > run as test" without having to go create a configuration, which is a really bad user experience.
Is there really no way to get an extension point especially for logging?