Reputation: 79
I have a few different integration flows on my application, currently they run based on a cron, they are instantiated from my MessagingGateway, so I send a header called "executionId" when my flows runs , so I would want to log all the activity that a "run" do.
any ideas on how to catch every log from my flow? for example logs like
"file x has been successfully transferred"
"Cannot delete local file x. The local file may be busy in some other process."
I would need the same logs output that are already on the messageProcessors / handlers, is there any way to catch them all and write it to database based on my executionId which is on the message Header?
currently I'm adding .log everywhere and onSuccessChannel on advice, but I think there should be a better way
Upvotes: 1
Views: 356
Reputation: 121177
For a global purpose you can use a WireTap
bean with a @GlobalChannelInterceptor
and particular channel names/patterns configuration. Essentially that log()
does exactly the same wireTap
, but in particular place. With a @GlobalChannelInterceptor
you'll add such a WireTap
into all those channels which bean names matches a configuration.
See more info in the Reference Manual:
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
Upvotes: 1