How to start a springboot application in debug mode?

How to start a springboot application in debug mode?

Using appliation-properties

Add this to application.properties file

debug=true

See https://docs.spring.io/spring-boot/docs/1.2.1.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels

logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR

The proper way to set the root logging level is using the property logging.level.root. See http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-custom-log-levels

logging.level.root=WARN

From command-line

Start the application with the –debug switch

$ java -jar myproject-0.0.1-SNAPSHOT.jar --debug

Using logback

Spring Boot provides also a nice starting point for logback to configure some defaults, coloring etc. the base.xml file which you can simply include in your logback.xml file. (This is also recommended from the default logback.xml in Spring Boot.

<include resource="org/springframework/boot/logging/logback/base.xml"/>

See

  1. https://github.com/spring-projects/spring-boot/tree/v1.2.1.RELEASE/spring-boot/src/main/resources/org/springframework/boot/logging/logback
  2. https://github.com/explorer436/programming-playground/tree/main/java-playground/request-logging/using-spring-CommonsRequestLoggingFilter

TODO

  1. https://www.baeldung.com/spring-debugging#bd-spring-boot
  2. https://docs.redhat.com/en/documentation/red_hat_support_for_spring_boot/2.3/html/reactive_application_development_guide/debugging-springboot-based-application_spring-boot