Hi -

Thanks for getting back to me so quickly - it's not a blocker, more of
a question. Apologies for the long answer

There's no special message content, and I had a (messy, admittedly,
but small CamelCustomLogMask) workaround for XML. The workaround used
the default implementation, and successfully masked all exchange
properties, as well as the XML content elements added to the keywords
- what I needed to debug.
However, now that I implemented another route in the same camel
context that sends JSON, I'm pretty sure that content cannot be
masked.
Basically, I thought each log component would be able to use a
different mask, not only the one named CamelCustomLogMask.

Since you asked, this is not great - and not tested recently, but it's
what I did
1. This is the workaround:
DefaultMaskingFormatter formatter = new DefaultMaskingFormatter() {
    @Override
    public String format(String source) {
        return super.format("<" + source).substring(1);
    }
}
add keywords, add formatter to to the camel registry with the name
CamelCustomLogMask

2. enable masking in the context

3. use the log component
.to("log:com.example.MyClass?level=DEBUG&showAll=true&multiline=true")

We're necessarily using a very old version of camel, 3.14.9

I think the fix may be one of
- don't try to log the whole exchange
- use an exchangeFormatter that masks with the default implementation
- mask in the logger itself

Best regards

On Sat, Oct 21, 2023 at 5:06 PM Claus Ibsen <claus.ib...@gmail.com> wrote:
>
> Hi
>
> Log masking is only a best effort. What kind of message content do you
> have, can you post an example.
> Also tell us what Camel version you use. And try with the latest release
> also.
>
> If you have a very special message content then you can also implement your
> own message formatter and do your own masking.
>
> On Sat, Oct 21, 2023 at 8:57 PM first last <first.last.leetc...@gmail.com>
> wrote:
>
> > Hello,
> >
> > When masking is enabled on a log statement that formats the entire
> > exchange, patterns used to identify message type (e.g.
> > source.startsWith("<")) fail, and the whole message body is logged.
> > I am unsure if this is a known issue, of I have configured masking
> > incorrectly.
> >
> > Best regards
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to