【问题标题】:How to use logging-channel-adapter in Spring Integration to log a message header value如何在 Spring Integration 中使用 logging-channel-adapter 来记录消息头值
【发布时间】:2011-03-28 11:21:59
【问题描述】:

我需要使用键“foo_bar”记录消息头的值,以便当该头的值为“baz”时,日志消息看起来像这样:

标头 foo_bar 的值:baz

如何使用窃听器和记录通道适配器来做到这一点?

【问题讨论】:

    标签: spring-integration spring-el


    【解决方案1】:

    使用 logging-channel-adapter 的表达式属性,并像这样设置wire-tap 和 logging-channel-adapter:

    <integration:channel id="channel1">
        <integration:interceptors>
            <integration:wire-tap channel="loggingChannel1"/>
        </integration:interceptors>
    </integration:channel>
    <integration:logging-channel-adapter 
        id="loggingChannel1" 
        expression="'Value of header foo_bar: '.concat(headers.foo_bar)" 
        level="DEBUG"
    />
    

    使用表达式属性时,根对象是spring集成消息。因此,表达式中的“headers”为您提供消息的 headers 映射。

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 1970-01-01
      • 2020-11-10
      • 2015-07-08
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多