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  

  • 相关阅读:
    Windows下MarialDB使用
    线程同步synchronized和ReentrantLock
    4种事务特性,5种隔离级别,7种传播行为
    Spring bean的作用域
    java经典30笔试题
    finally中的return
    springboot中Controller没有被扫描
    面试如何回答优化数据库
    Windows定时任务没有执行
    .Net应用程序打包部署总结
  • 原文地址:https://www.cnblogs.com/gifisan/p/6879465.html
Copyright © 2011-2022 走看看