On Mon, 10 Mar 2003, Manfred Wolff wrote:
> Date: Mon, 10 Mar 2003 09:06:38 +0100
> From: Manfred Wolff <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: [OT]Re: quick log4j question
>
> No, Rick, I don't. I have said: Put it in ANY directory, that contains
> to the classpath. It is a good Idea to build a group of property-files
> e.g. in WEB-INF/classes/ressources or any other directory.
>
If you are using ClassLoader.getResource() to load resources from inside
the class path (which I imagine that Log4J is doing), there is a very
definite difference between putting the properties file in
"/WEB-INF/classes" and "/WEB-INF/classes/resources" -- one will be found
and one will not.
The reason for this is that resource file names have a path structure just
like Java class names in a package -- to retrieve the resource file
"/WEB-INF/classes/log4j.properties", one would say:
ClassLoader cl = this.getClass().getClassLoader();
InputStream is = cl.getResourceAsStream("log4j.properties");
but, if you want "/WEB-INF/classes/resources/log4j.properties", you would
say this instead:
ClassLoader cl = this.getClass().getClassLoader();
InputStream is = cl.getResourceAsStream("resources/log4j.properties");
The right place to put your properties files, then, is wherever the
software that is loading them will look for them :-).
> But I don't know why evrybody will have a configuration in web.xml and a
> initialisation in the Actionsservlet. That is not need.
>
> Manfred
>
Craig
> Rick Reumann wrote:
> > On Sun, Mar 09,'03 (12:29 PM GMT+0100), Manfred wrote:
> >
> >
> >>The best you can do to place your property file in any directory that
> >>contains to the classpath (e.g. WEB-INF/classes ...) and load the file
> >
> >
> > So you are saying (in response to Dan's question) that it is best to
> > just keep the log4j.properties file in WEB-INF/classes and to not try
> > and move it to somewhere like WEB-INF/classes/resources ?
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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]