更改默认 Spring 集成 DirectChannel 日志记录
Alter default Spring Integration DirectChannel logging
目前默认情况下,Spring Integration 以以下格式写入调试日志:
DEBUG date time | producer-1 | o.s.i.c.DirectChannel | send line: 123 |
preSend on channel 'myChannel', message: GenericMessage [payload=myPayload(),
headers={content-length=XYZ, http_requestMethod=POST, errorChannel=errorChannel,
authorization=Bearer myExtremelyLongToken, replyChannel=replyChannel}]
上面的日志示例看起来相当简洁,但是当包含一个大的 JSON 负载和许多 header 时,它很快就会变得笨拙。
最大的贡献者是授权header。 header 可以包含数百个字符,这使得在 80 宽度的终端上几乎不可能有超过一条长消息。
是否有方法或是否可以编辑 DirectChannel 日志记录以排除授权 header?
理想情况下,我们也不喜欢在日志中重复包含授权令牌,因为它们是生产令牌。
我不得不相信有一些方法可以隐藏这些默认日志的某些部分。
嗯,无法在记录之前过滤掉消息的内容(还):https://github.com/spring-projects/spring-integration/issues/3222。
但是,您不能停止 org.springframework.integration
的 DEBUG 日志记录级别,而是在特定频道上使用 Wire-Tap 来捕获他们的消息并将它们转储到 LoggingHandler
使用自定义类别和特定 setLogExpression
在记录消息之前对其进行处理。该表达式可能会调用一些 bean(使用 @
运算符)并使用 #root
作为参数,这是用于记录的整个 Message
。只会记录该调用的结果。因此,您可以在要从此表达式调用的目标 bean 中自由构建任何过滤逻辑!
在文档中查看更多信息:
- Wire-Tap - https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-wiretap
- 记录通道适配器 - https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#logging-channel-adapter
- SpEL 支持 - https://docs.spring.io/spring-integration/docs/current/reference/html/spel.html#spel
目前默认情况下,Spring Integration 以以下格式写入调试日志:
DEBUG date time | producer-1 | o.s.i.c.DirectChannel | send line: 123 |
preSend on channel 'myChannel', message: GenericMessage [payload=myPayload(),
headers={content-length=XYZ, http_requestMethod=POST, errorChannel=errorChannel,
authorization=Bearer myExtremelyLongToken, replyChannel=replyChannel}]
上面的日志示例看起来相当简洁,但是当包含一个大的 JSON 负载和许多 header 时,它很快就会变得笨拙。
最大的贡献者是授权header。 header 可以包含数百个字符,这使得在 80 宽度的终端上几乎不可能有超过一条长消息。
是否有方法或是否可以编辑 DirectChannel 日志记录以排除授权 header?
理想情况下,我们也不喜欢在日志中重复包含授权令牌,因为它们是生产令牌。
我不得不相信有一些方法可以隐藏这些默认日志的某些部分。
嗯,无法在记录之前过滤掉消息的内容(还):https://github.com/spring-projects/spring-integration/issues/3222。
但是,您不能停止 org.springframework.integration
的 DEBUG 日志记录级别,而是在特定频道上使用 Wire-Tap 来捕获他们的消息并将它们转储到 LoggingHandler
使用自定义类别和特定 setLogExpression
在记录消息之前对其进行处理。该表达式可能会调用一些 bean(使用 @
运算符)并使用 #root
作为参数,这是用于记录的整个 Message
。只会记录该调用的结果。因此,您可以在要从此表达式调用的目标 bean 中自由构建任何过滤逻辑!
在文档中查看更多信息:
- Wire-Tap - https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#channel-wiretap
- 记录通道适配器 - https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#logging-channel-adapter
- SpEL 支持 - https://docs.spring.io/spring-integration/docs/current/reference/html/spel.html#spel