You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jim Lynch <jw...@sgi.com> on 2003/06/23 18:01:07 UTC

Logging via log4j and war file question

I recently switch from doing "install", "remove" deployments via a build
directory to "deploy", "undeploy" via a war file.  Unfortuantely my
logging has stopped working.  I've traced it to the following statement:

PropertyConfigurator.configure(getServletContext().getRealPath("/")+"/WEB-INF/classes/log4j.properties");

It appears the getRealPath method doesn't work with war files, so I'm a
bit stuck.  How can I configure my logging from a file within the war
file, or can I? 

Thanks,
Jim.

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


Re: Logging via log4j and war file question

Posted by Tim Funk <fu...@joedog.org>.
Somedays, I think I'm going senile. Ignore my second sentence.

-Tim

Tim Funk wrote:
> If log4j is nowhere else other than your war file - log4j.properties 
> should automajically be used.
> 
> Otherwise - you can use a ServletContextListener
> 
> -Tim
> 
> Jim Lynch wrote:
> 
>> I recently switch from doing "install", "remove" deployments via a build
>> directory to "deploy", "undeploy" via a war file.  Unfortuantely my
>> logging has stopped working.  I've traced it to the following statement:
>>
>> PropertyConfigurator.configure(getServletContext().getRealPath("/")+"/WEB-INF/classes/log4j.properties"); 
>>
>>
>> It appears the getRealPath method doesn't work with war files, so I'm a
>> bit stuck.  How can I configure my logging from a file within the war
>> file, or can I?
>> Thanks,
>> Jim. 


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


Re: Logging via log4j and war file question

Posted by Tim Funk <fu...@joedog.org>.
If log4j is nowhere else other than your war file - log4j.properties should 
automajically be used.

Otherwise - you can use a ServletContextListener

-Tim

Jim Lynch wrote:
> I recently switch from doing "install", "remove" deployments via a build
> directory to "deploy", "undeploy" via a war file.  Unfortuantely my
> logging has stopped working.  I've traced it to the following statement:
> 
> PropertyConfigurator.configure(getServletContext().getRealPath("/")+"/WEB-INF/classes/log4j.properties");
> 
> It appears the getRealPath method doesn't work with war files, so I'm a
> bit stuck.  How can I configure my logging from a file within the war
> file, or can I? 
> 
> Thanks,
> Jim. 


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


Re: Logging via log4j and war file question

Posted by Jason Bainbridge <ja...@jblinux.org>.
On Tue, 24 Jun 2003 00:01, Jim Lynch wrote:
> I recently switch from doing "install", "remove" deployments via a build
> directory to "deploy", "undeploy" via a war file.  Unfortuantely my
> logging has stopped working.  I've traced it to the following statement:
>
> PropertyConfigurator.configure(getServletContext().getRealPath("/")+"/WEB-I
>NF/classes/log4j.properties");

From a previous post (I'd include a link but I searched my local mailbox as 
the archives are notoriously hard to search):

Properties logProp = new Properties();
logProp.load(ActionServlet.getServletContext().getResourceAsStream("/WEB-INF/classes/log4j.properties"));
PropertyConfigurator.configure(logProp);

So you want getResourceAsStream instead seeing how the file is contained 
within a WAR file. :)

Regards,
-- 
Jason Bainbridge
http://jblinux.org

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


Re: Logging via log4j and war file question

Posted by Jim Lynch <jw...@sgi.com>.
Thanks for all the replies.  Finally something about this project that I
can really appreciate.  The soloution is to do NOTHING!  I love it.  8)

Thanks,
Jim.

Jim Lynch wrote:
> 
> I recently switch from doing "install", "remove" deployments via a build
> directory to "deploy", "undeploy" via a war file.  Unfortuantely my
> logging has stopped working.  I've traced it to the following statement:
> 
> PropertyConfigurator.configure(getServletContext().getRealPath("/")+"/WEB-INF/classes/log4j.properties");
> 
> It appears the getRealPath method doesn't work with war files, so I'm a
> bit stuck.  How can I configure my logging from a file within the war
> file, or can I?
> 
> Thanks,
> Jim.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

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