问题描述
我被迫在tomcat 6中部署的Web应用程序中使用自定义的封闭源代码库。它通过printStackTrace在stdout日志(catalina.out)中记录了大量异常,然后重新抛出它们来处理。有没有办法阻止或重新路由从webapp中部署的特定包中的异常记录? e.printStackTrace
打印到与System.err相似的控制台
在Tomcat中, catalina.sh
这一行将所有控制台错误重定向到catalina.out
这适用于整个Tomcat服务器。
$ CATALINA_BASE/logs/catalina.out 2>& 1&
所以简而言之,如果你不能修改源代码来使用log4j,可以尝试发送这个到catalina.sh中的另一个文件,但是再次这不是你想要的包特定的。
这样做只会以类似的方式膨胀另一个文件。
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?
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.outThis 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.
这篇关于如何从tomcat中部署的特定包中记录异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!