How jLo searches for a logger


The logger are not hierarchical in any means. This terms refers to how you usually name the loggers. They are mostly named afther the java package or class where they are used. It is like where the package structure is not truely such a hierarchical structure.

Let us start with a little example:

  <logger name="org.foo">
   ....
  </logger>

When you now call:

Logger logger = LogManager.getLogger("org.foo");

of you get the desired logger. But if you call:

Logger logger = LogManager.getLogger("org.foo.app.sql");

you will get the same logger. Because there is no logger for the given name jLo will try to find one. It will actually cut off the last part and then tries to find a logger. It will proceed until a logger is found or if nothing is left it will return the default logger.
In this case the search order is:
  1. org.foo.app.sql
  2. org.foo.app
  3. org.foo
When you try to get a logger like this:

Logger logger = LogManager.getLogger("org.jzonic");

This will return the default logger since there is no logger defined which starts with org.jzonic.