tags:

views:

57

answers:

1

Hey, I'm trying to create a loggers hierarchy in my application. (I'm using standard java logger) To do so, I'm creating first the "grandfather" of all loggers by simply call: (In a static block) Logger.getLogger("myapplication"); Then, every concrete logger ask for logger: Logger.getLogger("myapplication.package1.Main"); and I create his father: Logger.getLogger("myapplication.package2");

Now, I'm using JConsole in order to use RMX to change logging level. When I call the getLoggerParentName for myapplication.package1.Main, I get myapplication.package1, and for myapplication.package1 I get myapplication.

But setting the logger level of myapplication does not affect the child's level. (Although setting the myapplication.package1 level does affect the Main's logger level).

How come? Am I missing something? As far as I dug into the Logger class, I think this should work...

A: 

Each logger has its own level associated with it. If the level is set to 'null', this means 'inherit this logger's level from the parent logger'.

If the child logger is given a non-null level, then it won't inherit level changes from its parent.

Does myapplication.package1 have a level explicitly set? What happens if you print the result of getLevel() for each logger?

richj
When I call getLevel using JConsole, I get empty string. (I assume that means null)..
Udi
It worked. Fathers logging level was manually set. Thanks
Udi