Hidden gem of debugging - Gradle tomcat task

Usually, we start the development Tomcat instance using Studio with (Re)start action. In this case Studio starts separate Tomcat process and you can see application logs using either terminal window (on Windows) or Studio log panel.

You can do the same with Gradle task restart:

> ./gradlew restart

But there is one more option that is extremely useful if you try to debug something and deal with the exceptions and stack traces.

Meet tomcat Gradle task!

> ./gradlew deploy tomcat

It is handy if you need to change code and restart the application from IntelliJ. In this case you just open the embedded IntelliJ terminal and execute command there. Tomcat will be started right in this terminal and you will see all the logs:


But what makes it so cool is the exception view with hyper links! In case you face with an exception IntelliJ will highlight exception stack trace for you.


It’s pretty awesome, right?

:bulb: Do not forget to stop your Tomcat with Ctrl-C shortcut.