i’m working with a code they gave me to try to solve the errors, but until now, the Exception that is thrown only sends me to the line where the
log.error("Error saving data: " + e.toString());
is. i don’t know how to find out the correct line, because the e.printStackTrace() doesn’t output anything. The function is has this parts:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {...
try {...
} catch (Exception e) {
e.printStackTrace();
log.error("Error al almacenar los datos de usuario: " + e.toString());
}
but in the middle i can’t find any reference to an exception. how can i get the “catch” part to show me where the error is?
you need to pass exceptions stackTrace to your logger. If you type e.printStackTrace() it puts stack trace to System.err
proper way is to write something,
log.error(“your message”,e);
and log4j will handle object e, and prints stackTrace in your logger.