-
Notifications
You must be signed in to change notification settings - Fork 9
Logger Factory
jduquennoy edited this page Jul 14, 2015
·
4 revisions
The logger factory holds the configured loggers, and can provide you with any logger you may request. For that, it stores :
- A root logger, that always exists
- A list of logger, associated to their UTI identifiers (such as project.feature1.logger1, project.feature2, ...).
Imagine you have configured your system with only two loggers :
- The root logger
- A logger with a UTI of "project.feature1"
First, you request a logger with a UTI of "project.feature1". Quite easy, the logger factory will do that :
- Look for an existing logger with UTI "project.feature1". A logger is found.
- Return the found logger.
You request a logger with a UTI of "project.feature1.logger". Here is what the logger factory will do to satisfy this request :
- Look for an existing logger with UTI "project.feature1.logger". None is found.
- Look for an existing logger with UTI "project.feature1". A logger is found
- Create a generated logger with the found logger as parent (see the logger description page for more details on generated loggers).
- Register the generated logger with the originally requested UTI so that next time this UTI will be requested, the logger will be found in the existing loggers list.
- Return the generated logger.
You now request a logger with a UTI of "project2.anotherLogger". Here is what the logger factory will do :
- Look for an existing logger with UTI "project2.anotherLogger". None is found.
- Look for an existing logger with UTI "project2". None is found.
- Create a generated logger with the root logger as parent (see the logger description page for more details on generated loggers).
- Register the generated logger with the originally requested UTI so that next time this UTI will be requested, the logger will be found in the existing loggers list.
- Return the generated logger.
Note : All generated loggers will be removed from the list of existing loggers when a new logger is registered.