6

I have a mule flow within which I am logging the entire payload in String format by following code snippet

<logger level="ERROR" message="#[payload:java.lang.String]"/>

Now if the error occurs there really is no need to print the entire payload. The payload object in the message is null and the exception payload is populated with the relevant exception in it.

If I can print just the exception payload in String format, that would suffice. Does any one know how to log the exception payload from the message ?

Shiva
  • 20,575
  • 14
  • 82
  • 112
An And
  • 155
  • 1
  • 3
  • 14

4 Answers4

8
    <logger level="ERROR" message=" 
#[groovy:message.getExceptionPayload().getRootException().getMessage()]" /> 

The above code extracts the message related to the cause of exception.

Chanandler Bong
  • 403
  • 1
  • 11
  • 23
tortoise
  • 613
  • 1
  • 7
  • 19
3

Quite simply:

<logger level="ERROR" message="#[exception]"/>
Anton Kupias
  • 3,945
  • 3
  • 16
  • 20
2

small correction in the expression use:

[groovy:message.getExceptionPayload().getRootException().getMessage()]
user987339
  • 10,519
  • 8
  • 40
  • 45
Anil
  • 111
  • 6
0

If you want to save error into payload you need to transform it:

%dw 2.0
output application/json
---
{
    error: error.detailedDescription,
    errorType: (error.errorType.namespace default '') ++ ":" ++ (error.errorType.identifier default '') ,
    recoverable: false
}

So, into payload you have your error

daniel_mutu
  • 163
  • 1
  • 14