• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamically setting logging level (java.util.logging)

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic