Problem with loading custom appender using log4j p

2019-08-21 10:38发布

I'm working on an Eclipse RCP project comprised from multiple plugin projects, and having trouble load a custom appender using the following property file in log4j:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="eclipseErrorView" class="com.mypackage.EclipseLoggingAppender"> 
  </appender> 
<appender name="console" class="org.apache.log4j.ConsoleAppender"> 
    <param name="Target" value="System.out"/> 
    <layout class="org.apache.log4j.PatternLayout"> 
      <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/> 
    </layout> 
  </appender>

  <root> 
    <priority value ="warn" /> 
    <appender-ref ref="eclipseErrorView" /> 
  </root>
  <root>
    <priority value ="debug" /> 
    <appender-ref ref="console" />
  </root> 

</log4j:configuration>

But when coming to load this property file I get the following error:

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassNotFoundException: com.mypackage.EclipseLoggingAppender

Where should I include this package in order for log4j to recoginze it? Note that I'm working on multiple plugin projects, all of them use log4j for logging purposes...

Thanks

0条回答
登录 后发表回答