How can I log a header value in camel using spring DSL

后端 未结 4 925
鱼传尺愫
鱼传尺愫 2021-02-14 04:20

This seems like it should be simple, pardon the pun. I\'m trying to log a header in camel within a spring DSL route. I\'ve seen the answer for Java DSL but I\'ve been searching

相关标签:
4条回答
  • 2021-02-14 04:57

    In JAVA DSL

    from("logger")
    .log(LoggingLevel.INFO, "${in.headers.CamelFileName}")
    .end
    

    LoggingLevel is from org.apache.camel.LoggingLevel

    0 讨论(0)
  • 2021-02-14 04:59

    Asked this question some time back, and realized that I eventually found the answer so should post it here in case someone else finds this thread in a search. This works:

    <log message="ftping $simple{in.header.CamelFileName}" loggingLevel="DEBUG"/>
    
    0 讨论(0)
  • 2021-02-14 05:02

    Try the following, either will work:

    <log message="ftping ${header[CamelFileName]}"/>
    <log message="ftping ${headers.CamelFileName}"/>
    

    The $simple{...} syntax was added in Camel 2.5 to avoid clashes with Spring ${...} - it might be that you're using an older version?

    0 讨论(0)
  • 2021-02-14 05:02

    Not sure it's possible

    http://camel.apache.org/logeip.html

    Difference between log in the DSL and Log component The log DSL is much lighter and meant for logging human logs such as Starting to do ... etc. It can only log a message based on the Simple language.

    On the other hand Log component is a full fledged component which involves using endpoints and etc. The Log component is meant for logging the Message itself and you have many URI options to control what you would like to be logged.

    0 讨论(0)
提交回复
热议问题