user3092750
user3092750

Reputation: 125

Best approach to log filtered message body in Apache Camel

Our message body (XML) contains sensitive information which we don't want to log. What is the best approach to log the filtered message body? I'm defining my routes with Java DSL and would like to use log DSL.

Thank you very much YUsuf

Upvotes: 3

Views: 1359

Answers (1)

Robert Budźko
Robert Budźko

Reputation: 183

If you would like to stick to CamelLogProcessor (because this processor is invoked under the hood of log DSL), then it is possible to write own custom ExchangeFormatter and inject it into logger. Documentation might be useful.

Although mentioned processor does nothing special (but usually is totally sufficient):

public boolean process(Exchange exchange, AsyncCallback callback) {
    if (log.shouldLog()) {
        log.log(formatter.format(exchange));
    }
    callback.done(true);
    return true;
}

In such a case it might be good idea to write your own processor and route to it instead to log schema (if you have to use pretty DSL then write own component but I don't think it's what you really are after). Provided you has decided to route to your own implementation of Processor then you can log whatever you want to log (for example omit sensitive information) in whatever the way you prefer.

Camel's generic processor for logging is generic :), so project specific implementation worked quite well for me in both cases: sensitive information or limiting logging time.

Upvotes: 2

Related Questions