From the documentation at https://docs.spring.io/spring-boot/reference/features/logging.html#features.logging.console-output :
Answer from abaghel on Stack Overflowyou can also specify
debug=truein yourapplication.properties.When the debug mode is enabled, a selection of core loggers (embedded container, Hibernate, and Spring Boot) are configured to output more information.
Spring Boot 3.3.0 Native debug=true in application.properties No effect
java - How can I set the logging level with application.properties? - Stack Overflow
How do you debug spring application?
java - Spring Boot requests: to "re-run your application with 'debug' enabled" - how do I? - Stack Overflow
Videos
Update: Starting with Spring Boot v1.2.0.RELEASE, the settings in application.properties or application.yml do apply. See the Log Levels section of the reference guide.
logging.level.org.springframework.web: DEBUG
logging.level.org.hibernate: ERROR
For earlier versions of Spring Boot you cannot. You simply have to use the normal configuration for your logging framework (log4j, logback) for that. Add the appropriate config file (log4j.xml or logback.xml) to the src/main/resources directory and configure to your liking.
You can enable debug logging by specifying --debug when starting the application from the command-line.
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"/>
You can do that using your application.properties.
logging.level.=ERROR -> Sets the root logging level to error
...
logging.level.=DEBUG -> Sets the root logging level to DEBUG
logging.file=${java.io.tmpdir}/myapp.log -> Sets the absolute log file path to TMPDIR/myapp.log
A sane default set of application.properties regarding logging using profiles would be:
application.properties:
spring.application.name=<your app name here>
logging.level.=ERROR
logging.file=${java.io.tmpdir}/${spring.application.name}.log
application-dev.properties:
logging.level.=DEBUG
logging.file=
When you develop inside your favourite IDE you just add a -Dspring.profiles.active=dev as VM argument to the run/debug configuration of your app.
This will give you error only logging in production and debug logging during development WITHOUT writing the output to a log file. This will improve the performance during development ( and save SSD drives some hours of operation ;) ).
Sometimes I missed the required annotation or use the annotation wrongly to make it work. Is there any way to troubleshoot it? Besides copying from working example?
Adding debug=true to the application.properties or
debug: true in the application.yml, file should help. You'll get more detailed logging.
Generally, if you want to see more fine-grained log messages from all members of a given package, you can set that by adding a line such as:
logging.level.<package_name>=<LOGGING_LEVEL>
for example:
logging.level.org.springframework.context=DEBUG
These log messages may be helpful in finding the core of the problem (in this case why a given exception was thrown).
@Joe Doe's answer gives much more details, but in brief:
Add below in your application.yml:
debug: true