Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logger.entering and exiting methods

 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Has anyone used the entering() and exiting() methods from java.util.logging.Logger class. I cannot seem to get these to work. I have my LoggerHandler level set to Level.ALL, yet I do not get anything from these traces in the console. Other traces are working fine, Logger.info(), Logger.fine(), etc.,etc. Any help is appreciated!

thanks,
Barry
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have the Handler set to ALL but what about the Logger itself? It needs to be set to ALL also.
entering and exiting are at the FINER level. Can you publish FINER log messages?
[ February 19, 2003: Message edited by: Thomas Paul ]
 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmmmm... I guess I don't quite understand what the Handler is doing. If I set the Level for the Handler to Level.OFF, then I get no traces and if I set it to Level.ALL I get INFO traces (which is all I have) So I just assumed that if I set the Level for the Handler, then all of my Loggers that are using this Handler would use this level. But, I see that is not the case. I tried what you said, i.e. I set the Logger itself to Level.ALL and now I get the entering/exiting traces. Can you explain why this is?
many thanks,

Barry
 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason why the Logger and Handler has a level is this allows mutiple Logger's to have the same handler and also mutiple handler's to the same logger.
Eg.
Situation 1: you have one Hanlder that writes to a file, and this handler level is set to ALL. You also have two Loggers that are set to ALL, now we chnage the one logger to only log WARNING logs because we know there is no unresolved problems for the one logger, but we need to get all the logs of the other logger. now both loggers can have diffrent log levels that are published to the same file.
Situation 2: You have on logger that accepts all logging levels, and two handler, one goes to a file and the other one to the console. now we can set one logger's level to ALL and have a detailed logging to file and the console handler is set to INFO, so in the console we only see runtime logs and no trace logging.
In both situations we could have used two logger and two handler objects, but with this design we can remove one of the hander/logger and save memory usage. and just Imagine if you had to set up 50 logger's with the same log message for 50 handler's that published to logs to diffrent locations, now we can do it with one logger and just 50 handler's , that saves us 49 objects form being created.
[ February 20, 2003: Message edited by: hennie louw ]
 
Barry Andrews
Ranch Hand
Posts: 523
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I see now! Thanks for the good explanation!

Barry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic