PropertyConfigurator.configure() does like an absolute path and you still
can give it one using a relative web path in your webapp directory. You can
even specify the relative path your struts resource file ( if you chose to
do so ).
If you use a startup servlet, something like this should work:
MessageResources messages = (MessageResources)
getServletContext().getAttribute(Action.MESSAGES_KEY);
Properties props = new Properties();
try {
FileInputStream inFile = new
FileInputStream(getServletContext().getRealPath(messages.getMessage("Log.Pro
pertiesFile")) );
props.load(inFile);
inFile.close();
// manipulate what needs to be manipulated :-)
props.setProperty("log4j.appender.stdlog.File",
getServletContext().getRealPath(messages.getMessage("Log.Qwickrate")) );
props.setProperty("log4j.appender.ddrlog.File",
getServletContext().getRealPath(messages.getMessage("Log.DDR")) );
// configure the logging device
PropertyConfigurator.configure(props);
} catch (IOException io) {
System.out.println(io.getMessage());
}
----- Original Message -----
From: "Martin J. La Jeunesse" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 27, 2001 3:57 PM
Subject: RE: Has any one used struts and log4j successfully?
> I had a little trouble using PropertyConfigurator.configure() to log to a
> file: I wasn't exactly sure where to put the .lcf file so that servlets
> could find it. I ended-up coding an absolute location. I kind-of thought
it
> should go in the application directory under WEBAPPS or in the application
> web-inf, but that didn't seem to work. Other than that, works great!
>
> > -----Original Message-----
> > From: Sundar @eSaravana [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, February 27, 2001 11:02 AM
> > To: [EMAIL PROTECTED]
> > Subject: Has any one used struts and log4j successfully?
> >
> >
> > Has anyone used log4j with struts? I have used log4j before,
> > but I am new to
> > struts. So, I am just looking for a short cut. If you
> > have,could you please
> > send me some code fragments to start off.
> >
> > I would really appreciate it.
> >
> > Cheers.....!
> > Sundar
> >
>
>