Problem with loading custom appender using log4j property file

回眸只為那壹抹淺笑 提交于 2019-12-12 01:34:28

问题


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

来源:https://stackoverflow.com/questions/3953843/problem-with-loading-custom-appender-using-log4j-property-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!