Return to site

🍃🎓 SPRING CERTIFICATION QUESTION: How can you control logging with Spring Boot?

December 18, 2022

Answer:

Even though Spring Boot is an 'opinionated' framework, its true power comes with the possibility to customize each and every pre-configured layer.

When it comes to logging the following can be changed:

* log level of the core Spring loggers (container, Hibernate, Spring Boot):

--> specify --𝒅𝒆𝒃𝒖𝒈 or --𝒕𝒓𝒂𝒄𝒆 flag.

--> specify application property 𝒅𝒆𝒃𝒖𝒈=𝒕𝒓𝒖𝒆, 𝒕𝒓𝒂𝒄𝒆=𝒕𝒓𝒖𝒆.

* message color of console output.

* file output using 𝒍𝒐𝒈𝒈𝒊𝒏𝒈.𝒇𝒊𝒍𝒆 or 𝒍𝒐𝒈𝒈𝒊𝒏𝒈.𝒑𝒂𝒕𝒉 application property.

* logging level of specific classes or logging groups.

* specify different logging implementations by including libraries on the classpath (logback is used by default).

#spring #certificationquestion #vcp

Logging in Spring Boot 👉 https://www.baeldung.com/spring-boot-logging