Java – Junit4 unit tests running inside eclipse, using java.util.logging – cannot see log output

eclipsejavajava.util.loggingjunit4maven-3

Using Maven build system under eclipse.

I have just switched by project from using Apache Commons Logging to Java Utils Logging, as it has to live in an environment where Java Utils Logging is the main logger (Google App Engine), and other libraries that I use already use it (Restlet). One of the features I like in eclipse is to be able right click on a function thats marked with @test and select "Run as Junit Test". When I do this now, I see no logging output. I have created a file

src/test/java/resources/logging.properties

handlers = java.util.logging.ConsoleHandler

.level=INFO
my.great.package.level=FINE
java.util.logging.ConsoleHandler.level = FINE

But still I see nothing when running test inside Eclipse. Before it used to all work beautifully with commons logging and log4j. What am I doing wrong?

Thanks in advance,

Best Answer

I'm not sure if Java Logging can auto-detect configuration files in the same way that log4j can.

Have you tried specifying where the configuration file is for the test runner, e.g.:

-Djava.util.logging.config.file=path/to/logging.properties

You can add this to the system properties via the VM Arguments text box in the Eclipse Run Configurations dialog.

You can also configure the maven-surefire-plugin with the same system property so you get logging during your build - if desired.

Related Topic