Sorry I don't have an answer, someone else hopefully will. In general it is recommended to wrap Logger, not extend it. Take a look at ==> http://logging.apache.org/log4j/docs/TROUBLESHOOT.html#cce.
If you instead wrap Log4j as described in his book (p 161), and remove the factory key in your properties file, the problem will be resolved. I think the recommendation not to sub-class logger is a pretty strong one. There may be other solutions to your immediate problem but I don't know of one. -----Original Message----- From: Marcel's List Box [mailto:[EMAIL PROTECTED] Sent: Monday, December 06, 2004 6:54 AM To: [EMAIL PROTECTED] Subject: ClassCast when initializing custom Log4j in WebSphere EJB container. Hello, I've written my own XLogger extends Logger and I've been using it without problems in stand-alone apps and Web containers. In my log4j.properties I specify that my Factory should be used so 3rd party jars which use standard Logger also use my XLogger: log4j.loggerFactory=com.sdmc.XLoggerFactory log4j.categoryFactory=com.sdmc.XLoggerFactory Also, to debug commons stuff, i have commons-logging.properties stating: org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jF actory Now... i have a WebSphere 4.0 EAR with 1 web and 1 ejb module. When an ejb using XLogger is created i get a ClassCastException on XLogger. Probably a Logger is already instantiated before my log4j.properties is being read so the Logger singleton is a Logger, not an XLogger I tried putting log4j.properties in my ejb jar, i tried putting it in the root of the ear and adding it to the Manifest.mf. Now i may end up writing my own Configurator but **who is going to call it**? When using log4j in a web container you can have a Log4jInitServlet (start-up=1) to initialize log4j... but when in a ejb container... how is this Log4jInitBean going to be the first thing to be created? I have run out of options, just bought Ceki Gulcu's "Complete Log4j manual" but i cannot find an answer. On page 92 it says what not to do in case of WebSphere.. but doesn't say what to do... Think part of the problem might be in the fact that WebSphere uses commons-logging under the hood? Hope somebody can help me out! Thanks, - Marcel Heemskerk --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ------------------------------------------------------------------------------- This message and any included attachments are from Siemens Medical Solutions USA, Inc. and are intended only for the addressee(s). The information contained herein may include trade secrets or privileged or otherwise confidential information. Unauthorized review, forwarding, printing, copying, distributing, or using such information is strictly prohibited and may be unlawful. If you received this message in error, or have reason to believe you are not authorized to receive it, please promptly delete this message and notify the sender by e-mail with a copy to [EMAIL PROTECTED] Thank you --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
