1

There are many ways to log info with camel

  • .log -dsl
  • .to("log: ")
  • .wireTap("direct:myLogRoute")
  • .process(customLogProcessor)

All this can be mixed of course. On the other hand i have some requirements about logging:

  • log into an elastic search instance (http/rest, no problem to integrated with camel)
  • log the "MessageHistory" and some selected bodies and headers (at least incoming and outgoing and some intermediate)
  • minimize "pollution" of routes with statements like (log, wiretap etc)
  • minimize write access to elastic search or the cache in between -> one, probably big entry per exchanged handled

So what would be a good way to achieve all this (don't know if all are good ideas)?

Ideas that came to my mind:

  • override DefaultMessageHistory and enrich it with payload/header data for some selected nodes (or all nodes) - how to override DefaultMassageHistory?
  • define an interceptor that intercepts selected nodes and collects information (as separate property?) to be "logged" at the end

I don't want to reinvent the wheel. I hope there is a pattern or a set of pattern to be used here. Thanks in advance

dermoritz
  • 12,519
  • 25
  • 97
  • 185
  • 2
    A simple solution would be calling a route inside `onCompletion` callback. In that route use a bean to transform your Exchange into a suitable string then POST to REST endpoint – Alessandro Da Rugna Jan 09 '17 at 20:15
  • this is a nice idea indeed. The only problem remaining is how to save some intermediate bodies (is there also a solution out of the route?). I want to post the MessageHistory and some payloads. – dermoritz Jan 10 '17 at 07:18
  • 1
    I have the same requirement and ended up lugging around a custom "transaction summary" instance as an exchange property. My processors are responsible to augment the summary with all required intermediary results, states, etc. I use an `onCompletion` route to asynchronously send the transaction summary to our audit system. – Ralf Jan 10 '17 at 10:19
  • In our setup, we use the standard `.log(...)` DSL that simply log in local files and then we use a [log4j plugin](https://github.com/ryantenney/log4j-redis-appender) to sends also the log in a Redis DB (buffer before the ELK stack). – рüффп Jan 17 '17 at 22:17

0 Answers0