Skip to content
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, ...).

How the logger factory generates loggers

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 :

  1. Look for an existing logger with UTI "project.feature1". A logger is found.
  2. 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 :

  1. Look for an existing logger with UTI "project.feature1.logger". None is found.
  2. Look for an existing logger with UTI "project.feature1". A logger is found
  3. Create a generated logger with the found logger as parent (see the logger description page for more details on generated loggers).
  4. 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.
  5. Return the generated logger.

You now request a logger with a UTI of "project2.anotherLogger". Here is what the logger factory will do :

  1. Look for an existing logger with UTI "project2.anotherLogger". None is found.
  2. Look for an existing logger with UTI "project2". None is found.
  3. Create a generated logger with the root logger as parent (see the logger description page for more details on generated loggers).
  4. 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.
  5. Return the generated logger.

Note : All generated loggers will be removed from the list of existing loggers when a new logger is registered.

Clone this wiki locally