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  

  • 相关阅读:
    设计模式03-工厂方法
    设计模式02-抽象工厂
    设计模式01-什么是设计模式
    工作流activiti-03数据查询(流程定义 流程实例 代办任务) 以及个人小练习
    工作流activiti-02事物控制、流程引擎创建
    工作流activiti-01个人小结
    jQuery.extend 函数详解
    hibernate框架学习之数据查询(QBC)
    hibernate框架学习之多表查询helloworld
    hibernate框架学习之数据查询(HQL)helloworld
  • 原文地址:https://www.cnblogs.com/gifisan/p/6879465.html
Copyright © 2011-2022 走看看