Hello Michael, I created a Log4jInit servlet that sets up system variables, uniquely named for each webapp. The file path is stored in the system variable. The names are predictable, so you can put it in your config file. For instance, here is the relevant part of my lo4j.xml file:
<appender name="A2" class="org.apache.log4j.FileAppender"> <param name="File" value="${Barracuda.log.home}/main.log" /> <param name="Append" value="false" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n"/> </layout> </appender> The context name is "Barracuda" and all the system variables are set to in the format of [webapp name].log.home. Adding the postfix keeps the system variable more unique and unlikely to overwrite an existing one. The applicable web.xml entry looks like this: <servlet> <servlet-name>log4j-init</servlet-name> <servlet-class>org.enhydra.barracuda.core.util.logging.Log4jInit</servlet-class> <init-param> <!-- relative path to config file within current webapp --> <param-name>log4j-config</param-name> <param-value>WEB-INF/log4j.xml</param-value> </init-param> <init-param> <!-- config file re-reading specified in milliseconds... Note that if the webapp is served directly from the .war file, configureAndWatch() cannot be used because it requires a system file path. In that case, this param will be ignored. Set to 0 or don't specify this param to do a normal configure(). --> <param-name>log4j-cron</param-name> <param-value>5000</param-value> </init-param> <!-- optional param for use with a File Appender. Specifies a path to be read from a log4j xml config file as a system property. The property name is dynamically generated and takes on the following pattern: [webapp name].log.home In Barracuda's case, it would be "Barracuda.log.home". The path defaults to WEB-INF/logs directory, which is created if it doesn't exist, unless the webapp is running directly from a .war file. Note that, if specified, the value is an absolute path, not relative to the webapp. --> <!-- <init-param> <param-name>log4j-log-home</param-name> <param-value>/usr/local/logs/tomcat</param-value> </init-param> --> <load-on-startup>1</load-on-startup> </servlet> You can use this servlet by using the above configuration and downloading Barracuda-1.1.0 and using the plankton.jar which contains the general utility classes for the Barracuda Web Application Framework. http://barracuda.enhydra.org/software/downloads/barracuda-1.1.0.zip If you are looking for a web application framework, I highly recommend Barracuda. It is not another JSP presentation project. It is kind of like using Swing, only on the web. It uses XMLC compile pages and the DOM to manipulate the page. Barracuda components hide the intricacies of the DOM, but you can also use the DOM directly. Read about it here: http://barracuda.enhydra.org/cvs_source/Barracuda/index_details.html Let me know if you have questions. Jake Wednesday, July 17, 2002, 2:41:02 PM, you wrote: MD> Hi all, MD> I was wondering if there is a way to set the 'root' directory for MD> destination of log files. MD> The 'root' for my log4j setup is C:\jakarta-tomcat-4.0.3\bin MD> My Log4j configuration file is attached below. MD> I have created a DailyRollingFileAppender and set the 'file' as: MD> log4j.appender.A2.File=logfile MD> My "appender.A2" logfile appears in the directory MD> C:\jakarta-tomcat-4.0.3\bin\ MD> All is working fine - but I would like to be able to assign the 'root' MD> directory. MD> Can anyone offer advice. MD> My Log4j configuration file is as below: MD> ===================================================================== MD> # Log4j configuration file MD> log4j.rootCategory=DEBUG, A1, A2 MD> # Available levels are DEBUG, INFO, WARN, ERROR, FATAL MD> # A1 is a ConsoleAppender MD> log4j.appender.A1=org.apache.log4j.ConsoleAppender MD> log4j.appender.A1.layout=org.apache.log4j.PatternLayout MD> log4j.appender.A1.layout.ConversionPattern=%-5p [%t] - %m%n MD> # A2 is a DailyRollingFileAppender MD> log4j.appender.A2.File=logfile MD> log4j.appender.A2.DatePattern='.'yyyy-MM-dd MD> log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender MD> log4j.appender.A2.layout=org.apache.log4j.PatternLayout MD> log4j.appender.A2.layout.ConversionPattern=%-5p %d{ISO8601} [%t] - %m%n MD> log4j.appender.A2.append=true MD> _________________________________________________________________ MD> Join the world’s largest e-mail service with MSN Hotmail. MD> http://www.hotmail.com MD> -- MD> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> MD> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- Best regards, Jacob mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>