GAE how to see production exceptions?

I am getting an error, but not on my local machine. Is there a way to see an exception that is probably being thrown from production? In tomcat - the user will be able to see the exception as the servlet is returning its output

+2


source to share


1 answer


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

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

Something like that:



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());
        }
    }
}

      

And you can configure it to filter all pages in web.xml with the url "*".

PS: No Tomcat, GAE / J starts Jetty.

+6


source







All Articles