On 13 November 2011 09:25, Florian Semm <[email protected]> wrote:
> if we expect in a configuration an attribute like "name" or "class" and we
> got nothing, we should call this trigger_error() function.
>
> i haven't seen that the LoggerConfigurator class validate the configuration.
> The configurator still triggers errors if the config is incomplete.
>
You are right, of course. I have fixed this in trunk. There is warning
triggered now if 'name' or 'class' attributes are missing in the
appender node. Please update and retest.
I have also tried to make error messages more meaningful where possible.
If you're interested in how it works under the hood: there are now two
stages in configuring from an XML file:
1. An Adapter object converts the XML file to a PHP array. The
configuration values are not validated at this point, just the XML
structure. For example, the missing 'name' node should have been
reported here.
2. A Configurator object applies the configuration from the array to
the log4php hierarchy. Everything is validated.
It's the same for properties (ini) config files. They use a different
Adapter, but the same Configurator.
If you want to see what the translated configuration looks like, run:
$conf = new LoggerConfigurator();
print_r($conf->parse('log4php.xml'));
Regards,
Ivan