Let's say I am developing some kind of web application, and in the process I did not quite correctly write, say, the controller and throws me right at error.jsp. How can I track in which line the error and in general to bring the full stack of errors?

Anything but logging!

  • one
    This is called logging, and you will have to learn how to use it if you see yourself as a Java programmer. No options. - enzo
  • But it does not work. I do not see my logs in catalina. I launch everything from under IDEA - Loligan
  • IDEA shows console? If nothing is done, then tomcat, when started from external programs, writes logs to the console. - Sergey
  • @Sergey is not, the console is not where it is not suitable at all. There should be a way to achieve logging work - Loligan

1 answer 1

Here is Netbeans logging automatically inserts into try catch blocks

 try { ... throw new MyException(); ... } catch (MyException ex) { Logger.getLogger(MyClass.class.getName()).log(Level.SEVERE, null, ex); } 

Well written to the Weldfly log (and earlier to the Glassfish log).
Of course, anything can happen, but it is unlikely that it will work differently on Tomcate.
Maybe the filter (or Level.SEVERE it is called exactly there) is set to ignore logs for various parameters: error level - Level.SEVERE WARNIG INFO etc., subsystem - getLogger(String subsystem) parameter getLogger(String subsystem)

By the way, the Tomcat manual says:

This is a java.util.logging implementation of the system. The Apache Tomcat startup scripts (for example, jsvc, or running Tomcat from within an IDE) can be used.

If you run native scripts, then the logging system java.util.logging enabled automatically. And if you run from IDE, then you need to tweak something somewhere

  • Native logging that tomcat writes works (catalina shows) but what I'm trying to write to the log I'm not writing - Loligan