是否可以告诉 spring 云侦探不要记录密码等值?

Is it possible to tell spring cloud sleuth to not log values like passwords?

所以我在我的 spring 启动应用程序中启用了 Spring Cloud Sleuth,这发生了:

2021-03-03 19:11:11.164 DEBUG [OAuth2 service,b1e3783b06d8cc61,b1e3783b06d8cc61] 5056 --- [nio-8080-exec-5] o.s.web.client.RestTemplate              : Writing [{grant_type=[password], client_id=[myclientid], client_secret=[b0ea9376...], username=[rose], password=[mypassword]}] as "application/x-www-form-urlencoded"

正如您在最后看到的那样,Sleuth 记录了 password=[mypassword] 什么不好...一点都不好。

是否可以将 Sleuth 配置为不记录敏感数据?

正如您在开头看到的,这不是 Sleuth 记录的,而是 RestTemplate 记录的,记录器是 o.s.web.client.RestTemplate,它与 Sleuth 无关。 (Here 是执行此操作的行)。

Sleuth 与此日志事件有关的部分是:[OAuth2 service,b1e3783b06d8cc61,b1e3783b06d8cc61];您的服务名称、traceID 和 spanID,其中 none 应视为机密。

如果您不想 RestTemplate 注销这些详细信息,您可以将其日志级别设置为 INFOWARN 或更高。