多个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

log4j:ERROR A "org.apache.log4j.DailyRollingFileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.的更多相关文章

  1. log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.lo .

    log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a &quo ...

  2. log4j:ERROR setFile(null,true) call failed

    1.错误描述 log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: at java.io.FileOut ...

  3. log4j:ERROR Failed to rename [/log/xxx.log] to [/log/xxx.log.2016-11-23.log]

    Log4j报错: log4j:ERROR Failed to rename [/log/xxx.log] to [/log/xxx.log.2016-11-23.log] google了一下发现是个b ...

  4. 启动hadoop,没有启动namenode进程。log4j:ERROR setFile(null,true) call faild.

    启动hadoop,没有启动namenode进程.log4j:ERROR setFile(null,true) call faild.   解决办法: cd /home/hadoop/hadoop-en ...

  5. Activiti6.0 安装出错 log4j:ERROR setFile(null,true) call failed.

    由于要选择一款合适的流程引擎,需要在jbpm和Activiti之间做对比,我这边负责Activiti的测试. 看到Activiti官网(http://www.activiti.org/download ...

  6. log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: ..\logs\2010-1-19.log (系统找不到指定的路径。)

    log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: ..\logs\2010-1-19.log (系统找 ...

  7. 有效Log4j按指定级别定向输出日志到指定的输出文件地址配置Threshold,log4j中如何屏蔽父logger输出源rootlogger的additivity配置,log4j向多个文件记录日志

    log4j向多个文件记录日志 关键配置,指定想要的日志级别信息输出到指定的日志文件中: log4j.appender.errorLogger.Threshold=ERROR #扩展,可指定只在子类自己 ...

  8. 启用SQLite的Data Provider 运行WECOMPANYSITE时遇到ERROR CREATING CONTEXT 'SPRING.ROOT': ERROR THROWN BY A DEPENDENCY OF OBJECT 'SYSTEM.DATA.SQLITE'

    从网上下载的源码WeCompanySite,运行时报错 Error creating context 'spring.root': Error thrown by a dependency of ob ...

  9. 错误:error libGL.so: cannot open shared object file: No such file or directory

    Failed to load libGL.soerror libGL.so: cannot open shared object file: No such file or directory 启动e ...

随机推荐

  1. Servlet------>jsp自定义标签5(标签体内容改为大写)

    5.把标签体内容改为大写(tld中的配置我就省略了,详细请看jsp自定义标签1) import java.io.IOException; import javax.servlet.jsp.JspExc ...

  2. iOS 10 获取相册相机权限

            AVAudioSession *audioSession = [[AVAudioSession alloc]init]; [audioSession requestRecordPerm ...

  3. Writing a Discard Server 写个抛弃服务器 世上最简单的协议

    Netty.docs: User guide for 4.x https://netty.io/wiki/user-guide-for-4.x.html The most simplistic pro ...

  4. Pulsar

    The Apache Software Foundation Announces Apache® Pulsar™ as a Top-Level Project : The Apache Softwar ...

  5. ui-router 视图嵌套时指定二级视图显示默认页面

    当跳转到user页面时,右边的uiview是为空的,要点击了左侧的导航才能插入模板,如何在路由中设置二级视图的默认显示页面呢? app.config(function($stateProvider, ...

  6. Python高级特性(2):Closures、Decorators和functools(转)

    原文:Python高级特性(2):Closures.Decorators和functools 装饰器(Decorators) 装饰器是这样一种设计模式:如果一个类希望添加其他类的一些功能,而不希望通过 ...

  7. LInux中的物理内存管理

    2017-02-23 一.伙伴系统 LInux下用伙伴系统管理物理内存页,伙伴系统得益于其良好的算法,一定程度上可以避免外部碎片为何这么说?先回顾下Linux下虚拟地址空间的分布. 在X86架构下,系 ...

  8. Spring-ApplicationContext容器

    Spring ApplicationContext容器 ApplicationContext是spring中比较高级的容器.和BeanFactory类似,它可以加载配置文件中定义的bean,并将所有b ...

  9. Push h.264 rawdata to rtmp server

    Push h.264 rawdata to rtmp server /* The MIT License (MIT) Copyright (c) 2013-2015 SRS(ossrs) Permis ...

  10. mutex_lock

    多核处理器下,会存在多个进程处于内核态的情况,而在内核态下,进程是可以访问所有内核数据的,因此要对共享数据进行保护,即互斥处理. mutex_lock(struct mutex *lock)和mute ...