posted 21 years ago
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 ]
Any Body can be paid to write good code, but brilliant code can only come from passion