GAE怎么看生产异常? [英] GAE how to see production exceptions?

查看:59
本文介绍了GAE怎么看生产异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在生产环境中遇到错误,但在本地环境中却没有. 有没有办法查看生产中可能抛出的异常? 在tomcat中-当servlet返回其输出时,用户将能够看到异常

I'm getting an error on the production env but not on the local one. Is there a way to see the exception that is probably being thrown from production? In tomcat - the user will be able the see the exception as the servlet returns its output

推荐答案

您(管理员)可以在管理控制台的日志查看器中看到异常(包括完整的堆栈跟踪).

You (the administrator) can see the exception (including full stack trace) in the log viewer on the admin console.

如果要向用户显示异常stacktrace,可以安装一个Servlet过滤器以捕获所有内容,并将stacktrace打印到响应流(然后也应将它记录为SEVERE,以便仍将其显示出来.在日志中.)

If you want to display the exception stacktrace to your users, you can install a Servlet filter that catches everything and prints the stacktrace to the response stream (you should then log it as SEVERE also, in order to still have it show up in the log).

类似这样的东西:

public class ExceptionLogger implements Filter {

    @Override
    public void init(FilterConfig config) throws ServletException {
    }

    @Override
    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1,
        FilterChain arg2) throws IOException, ServletException {

        try{
           arg2.doFilter(arg0, arg1);
        } catch (Exception e) {
           Logger.getLogger("ExceptionLogger").log(Level.SEVERE,
              "request failed with an exception", e);
           e.printStacktrace(arg1.getWriter());
        }
    }
}

您可以将其设置为使用url模式"*"来过滤web.xml中的所有页面.

And you can set it to filter all pages in web.xml with a url-pattern of "*".

PS:没有Tomcat,GAE/J正在运行Jetty.

PS: There is no Tomcat, GAE/J is running Jetty.

这篇关于GAE怎么看生产异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆