简体   繁体   中英

Suppress some Spring boot specific logs

I am running a springboot application and I see that Spring boot logs every method call that is done. That means I get the following lines for every single method called:

Jan 31 08:40:28 hostname java: Jan 31, 2022 8:40:28 AM com.whatever.ClassName methodName

How do I suppress these kind of logs?

You can change the default loglevel springboot uses by setting it up into application.properties (or application.yml)

For example, you can go with (assuming you are using application.properties)

logging.level.root=warn
logging.level.org.springframework.web=debug
logging.level.org.hibernate=error

So you get debug messages for the web part, but root logging (everything but springframework.web) is set to warning, and hibernate logs only to error.

You can see more of this into the docs https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/boot-features-logging.html#:~:text=By%20default%2C%20Spring%20Boot%20logs,for%20example%2C%20in%20your%20application .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM