avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kerry Todyruik" <ke...@todyruik.com>
Subject Help with LogKitManager
Date Wed, 05 Dec 2001 20:32:09 GMT
I have Avalon and Excalibur release 4.0 installed.

I am having some difficulty getting LogKitManager working.

First, it appears that the DefaultLogKitManager will throw a
NullPointerException if a logger is not set:

.java.lang.NullPointerException
	at
org.apache.avalon.excalibur.logger.DefaultLogTargetFactoryManager.configure(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.setupTargetFactoryManager(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.configure(Unknown
Source)
	at
com.comczar.component.container.ComponentContainer.initialize(ComponentContainer.java:44)


A "SetALoggerYouDummyException" or just gracefully dealing with this
would have been more straightfforward for me.


Now that I figured that out, on to the next exception.  Here is my
intialize method for my container:

    public void initialize() throws ConfigurationException  {
	DefaultConfigurationBuilder builder = new
DefaultConfigurationBuilder();
	try {
	    Configuration systemconfig = builder.buildFromFile("myapp.xml");
	    Configuration roleconfig = builder.buildFromFile("myapp.roles");
	    Configuration logkitconfig = builder.buildFromFile("logkit.xml");
	    DefaultRoleManager roles = new DefaultRoleManager();
	    DefaultLogKitManager logkit = new DefaultLogKitManager();
	   
logkit.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("logmanager"));	    
	    logkit.configure(logkitconfig);	   
roles.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("container.roles"));
	    roles.configure(roleconfig);

	   
this.manager.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("container"));
	    //this.manager.setLogger(logkit.getLogger("comczar"));
	    this.manager.contextualize(new DefaultContext());
	    this.manager.setLogKitManager(logkit);
	    this.manager.setRoleManager(roles);
	    this.manager.configure(systemconfig);
	    this.manager.initialize();
	} catch (org.xml.sax.SAXException e) {
	    e.printStackTrace();
	    throw new ConfigurationException(e.getMessage());
	} catch (IOException e) {
	    e.printStackTrace();
	    throw new ConfigurationException(e.getMessage());
	}
    }


And my logkit.xml file:

<?xml version="1.0"?>

<logkit>
  <factories>
    <factory type="file"
class="org.apache.avalon.excalibur.logger.factory.FileTargetFactory"/>
  </factories>

  <targets>
    <file id="root">
      <filename>mylogfile.log</filename>
      <append>true</append>
    </file>
  </targets>

  <categories>
    <category name="root" log-level="DEBUG">
      <log-target id-ref="root"/>
    </category>
  </categories>
</logkit>


And here's the output when I initialize my container:

.DEBUG   28      [containe] (main): added new LogTargetFactory of type
file
E
Time: 0.951
There was 1 error:
1)
testCastorComponent(com.comczar.component.container.TestComponentContainer)
java.lang.NoSuchMethodError: org.apache.log.format.PatternFormatter:
method <init>(Ljava/lang/String;)V not found
	at
org.apache.avalon.excalibur.logger.factory.FileTargetFactory.getFormatter(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.factory.FileTargetFactory.createTarget(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.DefaultLogTargetManager.configure(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.setupTargetManager(Unknown
Source)
	at
org.apache.avalon.excalibur.logger.DefaultLogKitManager.configure(Unknown
Source)
	at
com.comczar.component.container.ComponentContainer.initialize(ComponentContainer.java:44)
	at
com.comczar.component.container.ComponentContainer.<init>(ComponentContainer.java:26)
	at
com.comczar.component.container.ComponentContainer.getInstance(ComponentContainer.java:31)
	at
com.comczar.component.container.TestComponentContainer.testCastorComponent(TestComponentContainer.java:25)
	at
com.comczar.component.container.TestComponentContainer.main(TestComponentContainer.java:79)




Thanks in advance,
Kerry Todyruik


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message