Skip to content
Advertisement

How to set java.util.logging.ConsoleHandler.level from command line arguments?

Current default global logging level is set to INFO in JRE_HOME/lib/logging.properties file.

I run the following from the command line to over-ride and set the level to FINE:

JavaScript

And, I use the below in my code:

JavaScript

The above message doesn’t get printed in the output.

If I change it to the below line, it prints successfully.

JavaScript

What am I missing?

Advertisement

Answer

The command switch -Djava.util.logging.ConsoleHandler.level=FINE just adds a system property entry. This is not used or read by the logging API.

Instead, all of the logging properties are managed by the LogManager. Here is a self contained program to show how you the LogManager can change settings:

JavaScript

Like @Andreas pointed out, you are going to create a new properties file with the adjusted parameters and set the system property to have the LogManager use the new properties file with your desired settings.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement