Home > Archive > Java Help > September 2004 > Setting log levels in java.util.logging
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Setting log levels in java.util.logging
|
|
| Steve Allan 2004-09-22, 9:00 pm |
| I'm about how to control logging levels. I'd expect this code:
import java.util.logging.Logger;
import java.util.logging.Level;
public class LoggerTest {
private static Logger log =
Logger.getLogger(LoggerTest.class.getName());
public static void main(String [] args) {
log.setLevel(Level.ALL);
log.severe("severe message");
log.warning("warning message");
log.info("info message");
log.fine("fine message");
log.finer("finer message");
log.finest("finest message");
}
}
to print all six log.* messages to the console, but instead I get the
default behavior of only printing severe, warning and info.
Where have I gone astray?
Thanks.
--
-- Steve
| |
| Steve Allan 2004-09-24, 4:03 pm |
| Hmm, after some experimentation, I can make the code below work as I
expect, but only if I create a logging.properties file with this setting:
java.util.logging.ConsoleHandler.level = ALL
and invoke the program as
java -Djava.util.logging.config.file=logging.properties LoggerTest
But, I'm still . I would expect that each approach should work
by itself. In other words, either set the level specifically in the
code, or set it at runtime via the logging.properties file. Having to
do both together seems odd to me.
Can anyone out there clarify this for me? I'm pretty sure I'm not using
the logger properly.
Thanks.
--
-- Steve
Steve Allan wrote:
> I'm about how to control logging levels. I'd expect this code:
>
> import java.util.logging.Logger;
> import java.util.logging.Level;
> public class LoggerTest {
> private static Logger log =
> Logger.getLogger(LoggerTest.class.getName());
> public static void main(String [] args) {
> log.setLevel(Level.ALL);
> log.severe("severe message");
> log.warning("warning message");
> log.info("info message");
> log.fine("fine message");
> log.finer("finer message");
> log.finest("finest message");
> }
> }
>
> to print all six log.* messages to the console, but instead I get the
> default behavior of only printing severe, warning and info.
>
> Where have I gone astray?
>
> Thanks.
>
> --
> -- Steve
|
|
|
|
|