Reputation: 2431
Can anyone tell me how to insert a new line in the message of a mule logger component?
For example, I have the following in the message for the logger:
Payload is: #[payload]
Inbound Headers: #[headers:INBOUND:*]
Outbound Headers: #[headers:OUTBOUND:*]
Exceptions: #[exception]
I'd like to insert a new line after each of the above. I've tried just adding \n to the end of each line, but that didn't work.
Upvotes: 10
Views: 22223
Reputation: 1
You can use this syntax with Mule 4:
My Input payload: #["\n"] #[payload]
Upvotes: 0
Reputation: 1488
//This should work. tested in mule 3.9 CE
<logger message="Payload is #[message.payloadAs(java.lang.String)] #[System.lineSeparator()] INBOUND HEADERS = #[headers:inbound:*]" level="INFO" doc:name="Logger"/>
Upvotes: 0
Reputation: 3323
we can you the below format
#['\n'] #['\n'] #['\n'] #['\n'] #[payload] #[System.getProperty('line.separator')]
Upvotes: 1
Reputation: 21
There are a couple of ways to do this:
1) Use: #[System.getProperty('line.separator')]
2) Use: #['\n'] eg: #['Hello\n'+payload+'Welcome to \n new line']
Upvotes: 2
Reputation: 43
use expression-transformer:
<expression-transformer expression="#[message.payload = message.payload + System.getProperty('line.separator')]" doc:name="Append CRLF"/>
Upvotes: 2
Reputation: 33413
Use MEL:
<logger
message="#['Payload is:'+payload+'\nInbound Headers: '+message.inboundProperties.entrySet()+'\nOutbound Headers: '+message.outboundProperties.entrySet()+'\nExceptions: '+exception]"
level="INFO" />
Upvotes: 19
Reputation: 2319
You could do something like this:
Payload is: #[payload] #[System.getProperty('line.separator')] Inbound Headers: ...
Upvotes: 6