SpringBoot 日志显示(truncate...),输出完整日志
本文地址:https://www.cnblogs.com/hchengmx/p/18119562
在查看SpringBoot查看日志中,http的response body会显示不全,如下:
2024-04-07 09:39:53.758|172.17.0.8|DEBUG|[qtp1763344271-7365]|org.springframework.core.log.LogFormatUtils.traceDebug(LogFormatUtils.java:119)|Writing [BaseResponseDTO(requestId=null, responseDateTime=Sun Apr 07 09:39:53 CST 2024, responseStatus=SUCCES (truncated)...]
原因是由于Spring Boot在输出日志的方法里面,当为Debug级别日志时,默认限制了最大输出为100。
public static String formatValue(@Nullable Object value, boolean limitLength) {
return formatValue(value, (limitLength ? 100 : -1), limitLength);
}
The logging of encoded and decoded values, for both Spring MVC and WebFlux, now logs the full value at TRACE, and up to 100 chars at DEBUG. However I'm keeping the ticket open because I had to introduce quite a bit of duplication and we need to find a better solution.
解决方案:添加上这行配置,使得responsebody 的日志级别为 TRACE
logging.level.org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor=TRACE
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· 单线程的Redis速度为什么快?
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码