Code Comments
Programming Forum and web based access to our favorite programming groups.I'mabout 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
Post Follow-up to this messageHmm, 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.