• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamically setting logging level (java.util.logging)

 
Dudley Dawson
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dudley Dawson
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic