Bug 1040274 - Cannot load own log4j library when custom log handler configures
Summary: Cannot load own log4j library when custom log handler configures
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Logging
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: James Perkins
QA Contact: Nikoleta Hlavickova
Russell Dickenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-11 05:40 UTC by Eiichi Nagai
Modified: 2018-12-04 16:36 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-19 16:17:50 UTC
Type: Bug


Attachments (Terms of Use)

Description Eiichi Nagai 2013-12-11 05:40:28 UTC
Created attachment 835122 [details]
reproducer

Description of problem:
When I set custome log4j log handler configuration, following exception occur.

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
	at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:248)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
	at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
	at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
	at org.apache.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:436)
	at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1004)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
	at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755)
	at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:896)
	at test.logger.TestLogger.<clinit>(TestLogger.java:13)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:270)
	at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:74)
	at org.jboss.logmanager.config.HandlerConfigurationImpl.<init>(HandlerConfigurationImpl.java:54)
	at org.jboss.logmanager.config.LogContextConfigurationImpl.addHandlerConfiguration(LogContextConfigurationImpl.java:145)
--- snip ---

Version-Release number of selected component (if applicable):
EAP 6.1
EAP 6.2

workaround:
Ignore exception, and restart.

Steps to Reproduce:
1. Unzip sample.zip under the jboss home directory.
2. Start standalone profile(./standalone.sh).
3. Move the admin-console logging page(http://localhost:9990/console/App.html#logging).
admin-console -> Profile -> Core -> Logging
4. Set custom handler, and save.
Handler -> Custom -> Add
Name : TEST_LOG
Log Level : INFO
Class Name : test.logger.TestLogger
Module : test.log
5. You can confirm ClassCastException in console/server log.

Comment 1 James Perkins 2013-12-11 17:00:36 UTC
Remove the log4j resource root (<resource-root path="log4j-1.2.17.jar"/>) from the module.xml and add a dependency on org.apache.log4j instead. The issue is log4j is already loaded as a dependency.

Comment 2 James Perkins 2013-12-11 17:05:41 UTC
Also after another look what are you trying to do here? Just wrap a log4j appender in a J.U.L handler? If so this can already be done with a custom-handler. It was buggy in 6.0 and 6.1, but should be fixed and working fine in 6.2.


Note You need to log in before you can comment on or make changes to this bug.