Configurator

The Configurator class has two static methods to create LoggerStores based on the configuration resource - which can be path to a file or an InputStream:

    public static LoggerStore createLoggerStore( final String configuratorType,
                                                 final String resource )
        throws Exception;
    public static LoggerStore createLoggerStore( final String configuratorType,
                                                 final InputStream resource )
        throws Exception;
      

The configurator type may be

  • Configurator.LOGKIT_EXCALIBUR for a LogKit Excalibur XML resource
  • Configurator.LOGKIT_SIMPLE for a LogKit Simple XML resource
  • Configurator.LOG4J_DOM for a Log4J XML resource
  • Configurator.LOG4J_PROPERTY for a Log4J property resource
  • Configurator.JDK14 for a JDK 1.4 property resource

loggerstore.properties

LoggerStore may also be configured via a property found in the jar META-INF:

META-INF/spice/loggerstore.properties
	  
and then using the InitialLoggerStoreFactory as:
final InitialLoggerStoreFactory factory = new InitialLoggerStoreFactory();
return factory.createLoggerStore( new HashMap() );
	  

The loggerstore.properties file contains the LoggerStore factory implementation class name and the path the the configuration resource. For example:

org.jcomponent.loggerstore.factory=org.jcomponent.loggerstore.factories.ExcaliburLogKitLoggerStoreFactory
org.jcomponent.loggerstore.file=/path/to/logconfig.xml
	  

The possible factory classes are:

  • org.jcomponent.loggerstore.factories.ExcaliburLogKitLoggerStoreFactory
  • org.jcomponent.loggerstore.factories.SimpleLogKitLoggerStoreFactory
  • org.jcomponent.loggerstore.factories.DOMLog4JLoggerStoreFactory
  • org.jcomponent.loggerstore.factories.PropertyLog4JLoggerStoreFactory
  • org.jcomponent.loggerstore.factories.JDK14LoggerStoreFactory

LoggerStoreFactory

One can also instantiate directly one of the above LoggerStoreFactory classes and call the create method with the appropriate configuration parameters. The configuration map may contain different resources indexed by the class name:

The possible factory classes are:

  • java.util.Properties
  • org.w3c.dom.Element
  • org.apache.avalon.configuration.Configuration
  • java.io.InputStream

For example for Log4J, configured via a DOM Element:
final LoggerStoreFactory factory = new DOMLog4JLoggerStoreFactory();
final Map config = new HashMap();
final Element element = ... // parsed via some JAXP parser
config.put("org.w3c.dom.Element", element);
return factory.createLoggerStore( config );