I neglected to say that, if I move my logger and appender definitions into JBoss's log4j.xml, I DO get the expected files. My question is: how can I ADD new loggers and appenders from a separate config file to the hierarchy that JBoss has already established?
-----Original Message----- From: Doubleday, Dennis [mailto:[EMAIL PROTECTED] Sent: Thursday, October 16, 2003 3:11 PM To: '[EMAIL PROTECTED]' Subject: App-server independent log4j logging My application needs to be deployable to both JBoss and Websphere (and possibly Weblogic in future). I am trying to use log4j in my app, but not having any success, even only with JBoss. Here's the deal--I want to include my own log4j.jar and log4j.xml in my WAR file. If the app server is using log4j itself, as JBoss does, my log4j.xml should only extend the configuration set up by JBoss. I don't want to add my Appenders to the JBoss log4j.xml, I want them in my WAR so it doesn't depend on the JBoss environment. Here is a snippet of what I am doing in my init servlet: String prefix = getServletContext().getRealPath("/"); String filePath = prefix + fileName; System.out.println ("Log4JConfigServlet - initializing log4j using file: " + filePath); try { if (fileName.indexOf("xml") != -1) { DOMConfigurator.configure(filePath); } else { PropertyConfigurator.configure(filePath); } Logger log = Logger.getLogger(Log4JConfigServlet.class); if (log.isInfoEnabled()) { log.info("Log4j initilized."); } } catch (Exception e) { I see both the println and the initial INFO log message in the JBoss console log, but the two FILE appenders don't seem to be getting created--I see debug output from the initial JBoss configuration but there is no debug output when my config file is processed. (The full file is at the end of the message). This approach worked in JBoss 3.0.6 but it mysteriously stopped when I upgraded to JBoss 3.2.1. Here's my log4j.xml: <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <!-- ================================= --> <!-- Preserve messages in a local file --> <!-- ================================= --> <!-- A size based file rolling appender --> <appender name="FALCONFILE" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="Falcon.log"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="500KB"/> <param name="MaxBackupIndex" value="20"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p [%c{1}.%M] %m%n"/> </layout> </appender> <appender name="FALCONHTML" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="Falcon.html"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="500KB"/> <param name="MaxBackupIndex" value="20"/> <param name="threshold" value="info"/> <layout class="org.apache.log4j.HTMLLayout"/> </appender> <appender name="FALCONCONSOLE" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <!-- The default pattern: Date Priority [Category] Message\n --> <param name="ConversionPattern" value="%-5p [%c{1}] %m%n"/> </layout> </appender> <!-- Falcon base logger --> <logger name="com.vocollect"> <level value="debug" /> <appender-ref ref="FALCONFILE" /> <appender-ref ref="FALCONHTML" /> </logger> </log4j:configuration> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]