Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Setting log levels in java.util.logging
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

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Allan
09-23-04 02:00 AM


Re: Setting log levels in java.util.logging
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

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Allan
09-24-04 09:03 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.