zoukankan      html  css  js  c++  java
  • log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.

    多个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 by
    log4j:ERROR [com.generallycloud.baseio.container.URLDynamicClassLoader@55740540] whereas object of type
    log4j:ERROR "org.apache.log4j.DailyRollingFileAppender" was loaded by [sun.misc.Launcher$AppClassLoader@18b4aac2].
    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 by
    log4j:ERROR [com.generallycloud.baseio.container.URLDynamicClassLoader@55740540] whereas object of type
    log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@18b4aac2].
    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  

  • 相关阅读:
    [RxSwift]4.4、Operator
    [RxSwift]4.3.6、ControlProperty
    [RxSwift]4.3.5、Variable (已弃用)
    [RxSwift]4.3.0、Observable & Observer 既是可监听序列也是观察者
    [RxSwift]4.2.2、Binder
    [RxSwift]4.2.1、AnyObserver
    Java重温学习笔记,Java8新特性:接口的默认方法
    Tomcat下,MySQL连接池的配置和使用(Tomcat9,MySQL5.5)
    MyEclipse2020配置JDK1.8及Tomcat9
    Java重温学习笔记,Java7新特性
  • 原文地址:https://www.cnblogs.com/gifisan/p/6879465.html
Copyright © 2011-2022 走看看