Ah so you use the servlet context to obtain the path. Are you using the xml file to configure log4j, didn't know one could do that. Anyway your sample will help me one way or the other. Thanks. Will try it soon.
Jacob Kjome wrote: > > What I did was use a dynamic variable which is expected to be set at > runtime. However, I use an xml config file. Not sure if you can do > this with a properties file???? > > Anway, I set up my FileAppender with something like this: > > <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> > > Notice the dynamic variable name. That is a system variable created > by my Log4jInit servlet. The name is based on the following scheme: > > [context name].log.home > > I grab the context name based on the name Tomcat gives to the tmpdir > it assigns to the context since I don't have access to the name within > the init() method of the servlet. Then, I assign the current system > path location from where the context is being deployed with fallback > in case the app is being served directly from a .war file, in which > case I would have no file access to my WEB-INF directory (which is > where I point the logging to ....within a "logs" directory). > > I'm attaching a sample build that is all set up to run. It requires > Ant-1.5 or greater. Make sure to put log4j-1.2.7.jar in the > web/WEB-INF/lib directory. The Log4jInit servlet is in the src > directory under the package: > org.enhydra.baracuda.core.util.logging > > You can configure its behavior via the web.xml file. That source code > is actually from the Barracuda project at http://barracuda.enhydra.org > <http://barracuda.enhydra.org/> . > > The context name is determined via the "app.name" value in the > build.xml. Modify to your liking. > > Make sure you have Tomcat-4.1.x installed with a user that has the > role of "manager". Then modify the sample.build.properties (or the > build.properties generated via the "sample.init" target) with the > appropriate values (catalina.home, manager.username, manager.password). > > Now you can put the build anywhere on your system and type: > > ant install > > This will install your webapp to Tomcat. Type "ant remove" to remove > the webapp. > > Note that the "sample.init" target with copy all sample.* files to * > and not overwrite them unless sample.clean or superclean is called. > This allows you to have templates and then another file that you can > make changes to. Modify the generated log4j.xml to your liking. A > filtered copy is done on this to apply the appropriate dynamic > variable name based on the value of "app.name". > > Hopefully that was a bit more clear than mud. If you have questions, > let me know. > > Jake > > At 09:36 AM 10/14/2002 +0800, you wrote: > >> Ok, I got my servlet working with the jsp taglib to output the logs. >> Many thanks to Muller, sk k for the help. I did see the manual but >> didn't notice it probably due to my cold medication :) . >> >> But there is another question, in the properties file, there is the >> statement >> "log4j.appender.R.File=logtags.log" which creates the file >> logtags.log which is fine but places >> the file in the root directory of my harddrive which is c:\ . How do >> I put it somewhere in my webapp using the >> configuration file without doing hardcoding the path in the >> properties file ? >> Help appreciated. >> >> >> >> >> Thomas Muller wrote: >> >>> | I'm trying to get my jsp to work with log4j, I need to know how to >>> set | up the log4j properties file to log to a file. >>> | Can someone provide a example ? Thanks. >>> >>> http://jakarta.apache.org/log4j/docs/manual.html >>> >>> -- >>> >>> Thomas >>> >>> >>> >>> >>> ************************************************************************* >>> Copyright ERA Technology Ltd. 2002. (www.era.co.uk >>> <http://www.era.co.uk/>). All rights reserved. The information >>> supplied in this Commercial Communication should be treated >>> in confidence. >>> No liability whatsoever is accepted for any loss or damage suffered >>> as a result of accessing this message or any attachments. >>> >>> ________________________________________________________________________ >>> This email has been scanned for all viruses by the MessageLabs SkyScan >>> service. For more information on a proactive anti-virus service working >>> around the clock, around the globe, visit http://www.messagelabs.com >>> <http://www.messagelabs.com/> >>> ________________________________________________________________________ >>> >>> -- >>> To unsubscribe, e-mail: >>> <mailto:[EMAIL PROTECTED]> >>> For additional commands, e-mail: >>> <mailto:[EMAIL PROTECTED]> >>> >>> >>> >> >> >> >> >> -- >> To unsubscribe, e-mail: >> <mailto:[EMAIL PROTECTED]> >> For additional commands, e-mail: >> <mailto:[EMAIL PROTECTED]> > >------------------------------------------------------------------------ > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>