You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Konstantin G <kg...@gmail.com> on 2006/05/22 17:34:38 UTC

Tomcat 4.1 - Problems referencing log4j.xml prop file within .war archive

Hello all,

I have attempted to research this problem on my own with little
progress.  I am new to the dev scene so please keep this in mind if
responding.  I have a log4j initialization servlet, and here is the
relevant snippet:

   public void init() throws ServletException {

   DOMConfigurator.configure("log4j.xml");

   }

I am building the .war with ant and I don't believe Tomcat unrar's the
archive when it is running.
I need the log4j.xml properties file to be inside the war archive,
since there will be different config files for each webapp.  I cannot
use  getServletContext().getRealPath("/") since:

"The real path returned will be in a form appropriate to the computer
and operating system on which the servlet container is running,
including the proper path separators. This method returns null  if the
servlet container cannot translate the virtual path to a real path for
any reason (such as when the content is being made available from a
.war archive)."

So my question is, how do I reference the log4.xml file for the
DOMConfigurator in these circumstances?

Tomcat 4.1.31

If more information is required to answer, please contact me and I
will respond momentarily.

thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 4.1 - Problems referencing log4j.xml prop file within .war archive

Posted by Konstantin G <kg...@gmail.com>.
Antonio,


 Your solutions works.

Thank You!

On 5/22/06, Antonio Petrelli <br...@tariffenet.it> wrote:
> Konstantin G ha scritto:
> > Hello all,
> >
> >
> >   public void init() throws ServletException {
> >
> >   DOMConfigurator.configure("log4j.xml");
> >
> >   }
> >
>
>
> change it to.
> DOMConfigurator.configure(getServletContext().getResource("/log4j.xml"));
>
> Ciao
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat 4.1 - Problems referencing log4j.xml prop file within .war archive

Posted by Antonio Petrelli <br...@tariffenet.it>.
Konstantin G ha scritto:
> Hello all,
>
>
>   public void init() throws ServletException {
>
>   DOMConfigurator.configure("log4j.xml");
>
>   }
>


change it to.
DOMConfigurator.configure(getServletContext().getResource("/log4j.xml"));

Ciao
Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org