Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2004

Tip: Looking for answers? Try searching our database.

Setting log levels in java.util.logging

Thread view: 
Steve Allan - 22 Sep 2004 22:37 GMT
I'm confused 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 - 24 Sep 2004 18:18 GMT
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 confused.  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

> I'm confused about how to control logging levels.  I'd expect this code:
>
[quoted text clipped - 20 lines]
>
> Thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.