GAE how to see production exceptions?
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 to share