Hi,

we had several requests to add a Log4j wrapper implementation to the core framework. Roberto Franchini also provided a first implementation that seems to work.
Now the open items are:

- add resource dependency (Log4j) to the uimaj-core POM
- add configuration functionality to configure the used logger class instead of changing the factoryConfig.xml

How does the logger configuration currently work:
The logger implementation that is used is specified in the factoryConfig.xml file like:
   <logger class="org.apache.uima.util.impl.JSR47Logger_impl"/>
To change the logger implementation the factoryConfig.xml must be changed.

How can the configuration work in the future:
Since the factoryConfig.xml file isn't a place where the user should change things, I would suggest to add
a configuration property specially for the logging configuration like:
   org.apache.uima.logger=<logger class>
If someone would like to change the logger for the framework the parameter must be specified. The factoryConfig.xml is not changed in that case. The code in the class FactoryConfigParseHandler (in UIMAFramwork_impl.java) is modified to check if the property is available. If it is available the specified class is used, if it is not available the class specified in factoryConfig.xml is used.

     if ("logger".equals(qName)) {
       if (context != CONTEXT_FACTORY_CONFIG) {
         throw new SAXException(I18nUtil
.localizeMessage(UIMAException.STANDARD_MESSAGE_CATALOG, Locale.getDefault(), "element_unexpected_in_context", new Object[] { "<logger>" }));
       }
       try {
         // get logger class
         mLoggerClass = Class.forName(attributes.getValue("class"));
         // get static method getInstance()
Method instanceMethod = mLoggerClass.getMethod("getInstance", new Class[0]);
         // invoke getInstance() method and retrieve default logger object
mDefaultLogger = (Logger) instanceMethod.invoke(null, new Class[0]);
       } catch (Exception e) {
         throw new SAXException(e);
       }
     }

Does this sounds useful and easy to use?

-- Michael


Reply via email to