log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

來源:互聯網
上載者:User

標籤:ppc   lease   gen   amp   read   adc   static   lin   blog   

 

多個classloader載入log4j時需要設定當前Thread的classloader為你自己的classloader

 

Thread.currentThread().setContextClassLoader(classLoader); //for log4j

 

摘自:org.apache.log4j.helpers.Loader

  /**   * If running under JDK 1.2 load the specified class using the   *  <code>Thread</code> <code>contextClassLoader</code> if that   *  fails try Class.forname. Under JDK 1.1 only Class.forName is   *  used.   *   */  static public Class loadClass (String clazz) throws ClassNotFoundException {    // Just call Class.forName(clazz) if we are running under JDK 1.1    // or if we are instructed to ignore the TCL.    if(java1 || ignoreTCL) {      return Class.forName(clazz);    } else {      try {    return getTCL().loadClass(clazz);      } catch(Throwable e) {    // we reached here because tcl was null or because of a    // security exception, or because clazz could not be loaded...    // In any case we now try one more time    return Class.forName(clazz);      }    }

 

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.log4j:ERROR The class "org.apache.log4j.Appender" was loaded bylog4j:ERROR [[email protected]40] whereas object of typelog4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [[email protected]].log4j:ERROR Could not instantiate appender named "main".log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.log4j:ERROR The class "org.apache.log4j.Appender" was loaded bylog4j:ERROR [[email protected]40] whereas object of typelog4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [[email protected]].log4j:ERROR Could not instantiate appender named "console".log4j:WARN No appenders could be found for logger (com.generallycloud.baseio.component.ssl.SSLUtil).log4j:WARN Please initialize the log4j system properly.

原文:http://www.cnblogs.com/gifisan/p/6879465.html  

 

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.