如何从集成流步骤中收集日志

How to collect logs from Integration Flow steps

我的应用程序有几个不同的集成流程,目前它们 运行 基于 cron,它们是从我的 MessagingGateway 实例化的,所以我在流程 运行s ,所以我想记录 "run" 所做的所有 activity。

关于如何从我的流中捕获每条日志有什么想法吗?例如

这样的日志

"file x has been successfully transferred"

"Cannot delete local file x. The local file may be busy in some other process."

我需要消息处理器/处理程序上已经存在的相同日志输出,有什么方法可以捕获它们并根据我在消息头上的 executionId 将其写入数据库?

目前我正在到处添加 .log 并根据建议添加 onSuccessChannel,但我认为应该有更好的方法

对于全局用途,您可以使用具有 @GlobalChannelInterceptor 和特定通道 names/patterns 配置的 WireTap bean。本质上 log()wireTap 完全相同,但在特定位置。使用 @GlobalChannelInterceptor,您可以将这样的 WireTap 添加到所有那些 bean 名称与配置匹配的通道中。

在参考手册中查看更多信息:

https://docs.spring.io/spring-integration/docs/5.2.0.BUILD-SNAPSHOT/reference/html/dsl.html#java-dsl-log https://docs.spring.io/spring-integration/docs/5.2.0.BUILD-SNAPSHOT/reference/html/core.html#channel-interceptors