Spring Boot关闭包的日志记录

Fra*_*ank 8 logging properties spring-boot

我更喜欢为业务逻辑抛出自己的异常.例如,我有一个类com.mine.exception.DuplicateClientException.是否有一些配置我可以关闭打包com.mine.exception包的堆栈跟踪?

就像是:

logging.level.com.mine.exception=OFF
Run Code Online (Sandbox Code Playgroud)

Sid*_*esh 6

在 application.properties 中,您可以添加 \xe2\x80\x98logging.level.*=LEVEL\xe2\x80\x99 其中 \xe2\x80\x98LEVEL\xe2\x80\x99 是 TRACE、DEBUG、INFO、WARN、ERROR 之一,致命,关闭。* 负责包/类。

\n\n

例如

\n\n
logging.level.root=WARN\nlogging.level.org.springframework.web=DEBUG\nlogging.level.org.hibernate=ERROR\n
Run Code Online (Sandbox Code Playgroud)\n\n

这意味着根记录器具有 WARN 级别。org.springframework.web 处于调试级别,但所有休眠文件仅记录错误。

\n