You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Svein Olav Bjerkeset <to...@bjerkeset.com> on 2005/01/03 09:12:19 UTC
Logging exceptions per webapp in Tomcat 5.5
After having read about how to setup logging in Tomcat 5.5 (http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html),
I have managed to set up Log4j to work with Tomcat 5.5.
However, when I set up indivdual logs for my webapps, only output generated from log statements in the code (Log4j
statements) end up in these logs. Exceptions still end up in catalina.out (which is common to all webapps). I would
like the exceptions to end up in the logfile belonging to the webapp that generated it.
I have tried adding the following line in my web/WEB-INF/classes/log4j.properties file without getting the wanted result:
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/mywebapp]=DEBUG, A1
To test the logging, I have written a short JSP which just thorws an exception.
>From what I read in the following article: http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg143230.html,
it seems that exceptions (and other output sent to stdout or stderr) can not be redirected and will always go to
catalina.out. Is this correct or is there a way to also redirect exceptions to individual log files basen on what
wabapp generated the exception?
Thanks in advance for any help,
Svein Olav Bjerkeset
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Logging exceptions per webapp in Tomcat 5.5
Posted by Shed Hollaway <sh...@bellsouth.net>.
Thanks I'll try that!
----- Original Message -----
From: "Will Hartung" <wi...@msoft.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Thursday, January 06, 2005 5:32 PM
Subject: Re: Logging exceptions per webapp in Tomcat 5.5
> > From: "Shed Hollaway" <sh...@bellsouth.net>
> > Sent: Thursday, January 06, 2005 6:59 PM
>
> > Svein
> >
> > Did you ever get an answer to you question? If so, how separate the
> logging
> > for webapps?
>
> The exceptions will log out to your log file if you actually bother to
> capture the exceptions and log them. The exceptions bubbling to the top in
> catalina.out are those that get out of your code.
>
> Don't let them out and capture them yourself. You can try (I haven't done
> this) to put a catch-all Filter at the top of your app that does nothing
but
>
> public void doFilter(ServletRequest req, ServletResponse resp, FilterChain
> chain)
> {
> try {
> filterChain.doFilter(request, response);
> }
> catch(Throwable t) {
> log.WARN(t);
> }
> }
>
> (making this work is left as an excercise for the reader)
>
> Regards,
>
> Will Hartung
> (willh@msoft.com)
>
>
> ---------------------------------------------------------------------
> 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
Re: Logging exceptions per webapp in Tomcat 5.5
Posted by Will Hartung <wi...@msoft.com>.
> From: "Shed Hollaway" <sh...@bellsouth.net>
> Sent: Thursday, January 06, 2005 6:59 PM
> Svein
>
> Did you ever get an answer to you question? If so, how separate the
logging
> for webapps?
The exceptions will log out to your log file if you actually bother to
capture the exceptions and log them. The exceptions bubbling to the top in
catalina.out are those that get out of your code.
Don't let them out and capture them yourself. You can try (I haven't done
this) to put a catch-all Filter at the top of your app that does nothing but
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain
chain)
{
try {
filterChain.doFilter(request, response);
}
catch(Throwable t) {
log.WARN(t);
}
}
(making this work is left as an excercise for the reader)
Regards,
Will Hartung
(willh@msoft.com)
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Logging exceptions per webapp in Tomcat 5.5
Posted by Shed Hollaway <sh...@bellsouth.net>.
Svein
Did you ever get an answer to you question? If so, how separate the logging
for webapps?
Shed.
----- Original Message -----
From: "Svein Olav Bjerkeset" <to...@bjerkeset.com>
To: <to...@jakarta.apache.org>
Sent: Monday, January 03, 2005 12:12 AM
Subject: Logging exceptions per webapp in Tomcat 5.5
> After having read about how to setup logging in Tomcat 5.5
(http://jakarta.apache.org/tomcat/tomcat-5.5-doc/logging.html),
> I have managed to set up Log4j to work with Tomcat 5.5.
>
> However, when I set up indivdual logs for my webapps, only output
generated from log statements in the code (Log4j
> statements) end up in these logs. Exceptions still end up in catalina.out
(which is common to all webapps). I would
> like the exceptions to end up in the logfile belonging to the webapp that
generated it.
>
> I have tried adding the following line in my
web/WEB-INF/classes/log4j.properties file without getting the wanted result:
>
>
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[
/mywebapp]=DEBUG, A1
>
> To test the logging, I have written a short JSP which just thorws an
exception.
>
> From what I read in the following article:
http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg143230.html,
> it seems that exceptions (and other output sent to stdout or stderr) can
not be redirected and will always go to
> catalina.out. Is this correct or is there a way to also redirect
exceptions to individual log files basen on what
> wabapp generated the exception?
>
> Thanks in advance for any help,
> Svein Olav Bjerkeset
>
> ---------------------------------------------------------------------
> 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