0

I'm forced to use custom closed source lib in my web app deployed in tomcat 6. It is logging a lot of exceptions in my stdout log (catalina.out) via printStackTrace and then rethrowing them for me to handle. Is there a way to prevent or reroute logging of exceptions from a specific package deployed in webapp?

mineralko
  • 1
  • 1
  • 1

2 Answers2

2

e.printStackTrace prints to the console similar to System.err

In Tomcat, the catalina.sh has this line which redirects all console errors to catalina.out This applies for the Tomcat server as a whole.

"$CATALINA_BASE"/logs/catalina.out 2>&1 & 

So in short, if you cant tinker with the source code to use log4j, you could try sending this to another file within the catalina.sh, but again this would not be package specific as you want.

And this would just bloat another file in a similar manner.

JoseK
  • 31,141
  • 14
  • 104
  • 131
1

How about calling that segment within a try/catch segment, thus catching the exception before your app dies, adding it to log4j (or any other logging mechanism)

Yishai Landau
  • 620
  • 4
  • 14
  • I am caching them (I have to, they are not runtime exceptions) and they do not kill the app as I'm handling (ignoring) them. It is just that they get sent to my tomcat log via printStackTrace (my guess at least) WITHIN the library BEFORE they are thrown to me. I don't want them there and can't change that (closed source). They are just hogging up my catalina.out as I get around 300 of them daily making it difficult to find exceptions that are really able to kill my app. – mineralko Nov 18 '10 at 23:32