wood burning stoves 2.0*
The moose likes Java in General and the fly likes Dynamically setting logging level (java.util.logging) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Dynamically setting logging level (java.util.logging)" Watch "Dynamically setting logging level (java.util.logging)" New topic
Author

Dynamically setting logging level (java.util.logging)

Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
Hi-
I'm trying to dynamically set the level of the root logger so that all other loggers will use the new level. According to the documentation (http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html#1.3):
Loggers keep track of their parent loggers in the logging namespace. A logger's parent is its nearest extant ancestor in the logging namespace. The root Logger (named "") has no parent. Anonymous loggers are all given the root logger as their parent. Loggers may inherit various attributes from their parents in the logger namespace. In particular, a logger may inherit:

* Logging level. If a Logger's level is set to be null then the Logger will use an effective Level that will be obtained by walking up the parent tree and using the first non-null Level.
* Handlers. By default a Logger will log any output messages to its parent's handlers, and so on recursively up the tree.
* Resource bundle names. If a logger has a null resource bundle name, then it will inherit any resource bundle name defined for its parent, and so on recursively up the tree


What I'm doing:


and the output:


I don't know why my logger is not inheriting level FINEST from the root logger

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Which handler are you using for this logger ? If you are using the ConsoleHandler, its default level is INFO. So even if you change the level of your root logger to FINEST, messages below INFO won't be printed to the console. You have to use the following in your logging.properties :


Then, if you change the level of your root logger to FINEST, the "child" logger should also have the same level.


[My Blog]
All roads lead to JavaRanch
Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
Christophe Verré wrote:Which handler are you using for this logger ? If you are using the ConsoleHandler, its default level is INFO. So even if you change the level of your root logger to FINEST, messages below INFO won't be printed to the console. You have to use the following in your logging.properties :


Then, if you change the level of your root logger to FINEST, the "child" logger should also have the same level.


yup - that was it. wonderful. thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically setting logging level (java.util.logging)
 
Similar Threads
logging with log4j
Logging "FINEST" messages using java Logger
logging in SUN AS and JSR047
Java Mail Project
how to suppress java.util.logging messages