You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Robert van der Linden <Li...@zorgdomein.nl> on 2016/05/30 07:42:29 UTC

Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Hi,

we're using Camel (in Scala) for our application, which handles messages that contain data that should not be exposed to our logging facility. However, when a org.apache.camel.CamelExchangeException with the error "Cannot write body" occurs, the body of the messages is dumped in the log, like this:
Failed delivery for (MessageId: ID-#### on ExchangeId: ID-####). On delivery attempt: 8 caught: org.apache.camel.CamelExchangeException: Cannot write body:
This is not acceptable for our case.

Is there a way to prevent Camel from logging the message body in this case, or in general?

Best,
Robert.

Re: Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Posted by arno noordover <an...@gmail.com>.
In 2.17.2 and 2.18.0 a patch will be available.
Only the name of the class will be returned in the exception message.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-logs-whole-message-body-in-case-of-org-apache-camel-CamelExchangeException-Cannot-write-body-tp5783240p5783891.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 9, 2016 at 10:00 PM, rvdlinden <Li...@zorgdomein.nl> wrote:
> Thanks for your reply. When i look into the source code of the
> org.apache.camel.component.mina2.Mina2Helper, from which this
> CamelExchangeException originates, i see that writeBody() includes the body
> to the Exception's message String. Maybe i'm missing something, but I don't
> see how a setting on the Error Handler could fix that without omitting the
> whole exception message. We do use Camel 2.17, yet it logs the full message
> body in the case of this exception.
>

Then log a JIRA to make camel-mina2 improved to not output the body in
that exception.
http://camel.apache.org/support.html

And you are welcome to work on a patch / PR to fix that
http://camel.apache.org/contributing.html

> I think what's left for us is either to somehow catch all
> CamelExchangeExceptions, match for the 'cannot write body' in the
> Exception's message string and throw a filtered exception that does not
> contain the message's body; or not use Mina2, but use a different transport
> library (we're actually considering camel-mllp, but that needs more
> research). Do you see any other possibility to solve this?
>

You can configure error handler to use log level OFF but I guess you
maybe still want some kind of error logging if an error happens.
But you can tweak how often is logged and if any redelivery attempts
is logged etc.

But yeah you can certainly also do a catch all and filter/change the
exception as you pleaase.


> Best,
> Robert.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-logs-whole-message-body-in-case-of-org-apache-camel-CamelExchangeException-Cannot-write-body-tp5783240p5783808.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Posted by arno noordover <an...@gmail.com>.
Should we put the canonical name of the class in the message?



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-logs-whole-message-body-in-case-of-org-apache-camel-CamelExchangeException-Cannot-write-body-tp5783240p5783832.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Posted by rvdlinden <Li...@zorgdomein.nl>.
Thanks for your reply. When i look into the source code of the
org.apache.camel.component.mina2.Mina2Helper, from which this
CamelExchangeException originates, i see that writeBody() includes the body
to the Exception's message String. Maybe i'm missing something, but I don't
see how a setting on the Error Handler could fix that without omitting the
whole exception message. We do use Camel 2.17, yet it logs the full message
body in the case of this exception.

I think what's left for us is either to somehow catch all
CamelExchangeExceptions, match for the 'cannot write body' in the
Exception's message string and throw a filtered exception that does not
contain the message's body; or not use Mina2, but use a different transport
library (we're actually considering camel-mllp, but that needs more
research). Do you see any other possibility to solve this?

Best,
Robert.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-logs-whole-message-body-in-case-of-org-apache-camel-CamelExchangeException-Cannot-write-body-tp5783240p5783808.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel logs whole message body in case of org.apache.camel.CamelExchangeException "Cannot write body:"

Posted by Claus Ibsen <cl...@gmail.com>.
You can configure error handler to turn off message history logging

And from 2.17 onwards its not logging the body by default.

On Mon, May 30, 2016 at 9:42 AM, Robert van der Linden
<Li...@zorgdomein.nl> wrote:
> Hi,
>
> we're using Camel (in Scala) for our application, which handles messages that contain data that should not be exposed to our logging facility. However, when a org.apache.camel.CamelExchangeException with the error "Cannot write body" occurs, the body of the messages is dumped in the log, like this:
> Failed delivery for (MessageId: ID-#### on ExchangeId: ID-####). On delivery attempt: 8 caught: org.apache.camel.CamelExchangeException: Cannot write body:
> This is not acceptable for our case.
>
> Is there a way to prevent Camel from logging the message body in this case, or in general?
>
> Best,
> Robert.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2