I need help with getting log4j working in RAD7. I had to convert yesterday from WSADS 5.1 to RAD7. Using WSADS 5.1 my log4j worked perfectly. But using RAD7 my log4j is totally ignored and none of my logging messages appear at install. Instead, thousands of lines of log4j messages appear that are coming from, among others:
org.apache.commons.digester.Digester, org.apache.struts.tiles.xmlDefinition.XmlDefinition,
org.springframework.beans.factory.support.DefaultListableBeanFactory,
org.apache.commons.beanutils.ConvertUtils
I've been struggling for going on two years trying to get log4j to work in WSADS6 and now in RAD7. My last job used WSADS6 and I never could get log4j to work in it. At my current company using WSADS 5.1 I had perfect logging of log4j.
I wrote a long review of a book about log4j over a year ago which you can read on
www.amazon.com at:
http://www.amazon.com/Apache-Log4j-Second-Samudra-Gupta/dp/1590594991/ref=pd_bbs_sr_1/103-0698628-5488656?ie=UTF8&s=books&qid=1179957639&sr=8-1 I've tried all the obvious things with no success to get log4j to work in RAD7. I have the log4j jar file in the lib directory of the dynamic web application. I set the classloader to look at the application first, which is done in the Websphere 6.1 (test) appserver.
Below I have pasted the log4j parameters that I set in web.xml. These worked perfectly in WSADS 5.1 but apparantly are being ignored in RAD7:
<web-app id="WebApp">
<display-name>tuesRoundup</display-name>
< !--<br /> Location of the Log4J config file; either a "classpath:" location<br /> (e.g. "classpath:myLog4j.properties"), an absolute file URL<br /> (e.g. "file:C:/log4j.properties), or a plain path relative to the web application<br /> root directory (e.g. "/WEB-INF/log4j.properties").<br /> -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
< !--<br /> Whether the web app root system property should be exposed, allowing for log file paths <br /> relative to the web application root directory. Default is "true"; specify "false" to<br /> suppress expose of the web app root system property.<br /> -->
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>true</param-value>
</context-param>
< !--<br /> By default, this configurer automatically sets the web app root system property,<br /> for "${key}" substitutions within log file locations in the Log4J config file, <br /> allowing for log file paths relative to the web application root directory.<br /> The default system property key is "webapp.root", to be used in a Log4J config<br /> file like as follows:<br /> log4j.appender.myfile.File=${webapp.root}/WEB-INF/demo.log<br /> Alternatively, specify a unique context-param "webAppRootKey" per web application.<br /> For example, with "webAppRootKey = "demo.root":<br /> log4j.appender.myfile.File=${demo.root}/WEB-INF/demo.log <br /> -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>
< !--<br /> Interval between config file refresh checks, in milliseconds. If not specified,<br /> no refresh checks will happen, which avoids starting Log4J's watchdog
thread <br /> -->
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>3000</param-value>
</context-param>
... snip ...
<
servlet>
<servlet-name>log4jConfigServlet</servlet-name>
<display-name>Spring Log4j Config Servlet</display-name>
<servlet-class>org.springframework.web.util.Log4jConfigServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
I tried going to "The link provided by Cameron McKenzie for Websphere classloader [www.techincalfacilitation.com" but there was nothing on that web page about log4j that I could find.
Can anybody suggest anything to get log4j to work in RAD7? I'm at my wits end about this. Well, actually there is one last thing I am going to try. I'm going to change the web.xml to use a listener instead of a servlet. Below is the explanation of why, maybe, this could possibly help:
"... Bootstrap servlet for custom Log4J initialization in a web environment. Delegates to Log4jWebConfigurer (see its javadoc for configuration details). Note: This servlet should have a lower load-on-startup value in web.xml than ContextLoaderServlet, when using custom Log4J initialization. Note that this class has been deprecated for containers implementing Servlet API 2.4 or higher, in favor of Log4jConfigListener...."