NopeCharon opened a new issue, #801:
URL: https://github.com/apache/logging-log4cxx/issues/801

   `OptionConverter::selectAndConfigure` loads the requested configurator class 
with `Loader::loadClass(clazz)` and `Class::newInstance()` without catching the 
exception they throw. If the class name is unknown, 
`helpers::ClassNotFoundException` propagates to the caller.
   
   The class name comes from the `LOG4CXX_CONFIGURATOR_CLASS` environment 
variable during default configuration. So a misspelt or unregistered class name 
in that variable makes the first `LogManager::getLogger()` call throw, because 
neither `DefaultConfigurator::configure` nor `Hierarchy::ensureIsConfigured` 
catches it. `DefaultConfigurator::configureFromFile` is also aborted instead of 
trying the remaining candidate files.
   
   Reproduction (current master, Linux), with a `log4cxx.properties` file in 
the working directory:
   
   ```
   $ LOG4CXX_CONFIGURATOR_CLASS=org.example.Bogus ./app
   terminate called after throwing an instance of 
'log4cxx::helpers::ClassNotFoundException'
     what():  Class not found: org.example.Bogus
   ```
   
   or directly:
   
   ```cpp
   OptionConverter::selectAndConfigure(File(LOG4CXX_STR("log4cxx.properties")),
       LOG4CXX_STR("org.example.NoSuchConfigurator")); // throws 
ClassNotFoundException
   ```
   
   Expected: an error is written to the Log4cxx internal log and 
`ConfigurationStatus::NotConfigured` is returned. That is what already happens 
when the class exists but is not a `Configurator` ("Could not instantiate 
configurator [...]"), and it matches how 
`OptionConverter::instantiateByClassName` handles unknown appender/layout 
classes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [I] An unknown LOG4CXX_CONFIGURA... NopeCharon (via GitHub) via notifications

Reply via email to