Am 09.02.2012 17:49, schrieb Ivan Habunek:
On 9 February 2012 08:40, Florian Semm<[email protected]> wrote:
We have forgot the option 'logger' under 'rootLogger'. It is maybe better to
trigger a notice 'you have called an unkown logger', than to return a logger
with the configuration of the root-logger. To locate the error would be much
easier.
This is by design. Logger::getLogger() will construct a new logger and
place it in a hierarchy. Loggers in a hierarchy inherit settings from
their first ancestor. Your logger therefore inherited settings from
the root logger since no closer ancestor exists.
Imagine the following imaginary situation: Let's say you have a couple
of classes in your project, here's their qualified class names:
\myproject\database\DBReader
\myproject\database\DBWriter
If each class has it's own Logger, and the Logger is named the same as
the qualified class name, then the loggers will be placed in the
hierarchy accordingly [1].
--rootLogger
|--myproject
|--database
|--DBReader
|--DBWriter
Now, if you have in your config file a configuration for a logger
named "myproject\database" then both DBReader and DBWriter (and any
other class in that part of the namespace) will inherit the
configuration from "myproject\database" since it's their first
ancestor.
Because of this we don't want to have warnings for loggers which are
not explicitly configured in the config file. We don't want to
configure every individual logger since there could be a lot of them.
We want implicit inheritance.
Franky, though, I have not used this functionality too much. Writing
better docs and real-world usage examples is on my todo list.
Regards,
Ivan
[1] Well this isn't strictly true at the moment, since backslash won't
be detected as a delimiter in version 2.2, only dots (Java style). So
you would have to name the loggers "myproject.database.DBReader", etc.
But in the next version backslash will also work, it was discussed on
the mailing list recently.
but in my example the configuration was wrong and nothing went wrong.
We're wondering why the hell is our logger not writing anything in this
log-file. I have no good idea to solve the problem/case, without
breaking the inheritance.