How do you insert a newline in message body of mule logger component
17,944
Solution 1
Use MEL:
<logger
message="#['Payload is:'+payload+'\nInbound Headers: '+message.inboundProperties.entrySet()+'\nOutbound Headers: '+message.outboundProperties.entrySet()+'\nExceptions: '+exception]"
level="INFO" />
Solution 2
You could do something like this:
Payload is: #[payload] #[System.getProperty('line.separator')] Inbound Headers: ...
Solution 3
use expression-transformer:
<expression-transformer expression="#[message.payload = message.payload + System.getProperty('line.separator')]" doc:name="Append CRLF"/>
Solution 4
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']
Solution 5
we can you the below format
#['\n'] #['\n'] #['\n'] #['\n'] #[payload] #[System.getProperty('line.separator')]
Author by
Gary Sharpe
LinkedIn: http://www.linkedin.com/in/garysharpe1/ Udemy: https://www.udemy.com/u/garysharpe/ GitHub: https://github.com/gmsharpe
Updated on June 09, 2022Comments
-
Gary Sharpe almost 2 years
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.
-
Seba about 11 yearsIt would still be better to use System.getProperty('line.separator') instead of \n to make it closs-platform.
-
David Dossot about 11 years@Seba Sounds good, but first we would need to make sure that
\n
isn't already interpreted by MVEL asSystem.getProperty('line.separator')
. -
ng10 almost 3 years#['\n'] is best and simplest option of all - thank you!
-
Eric Aya over 2 yearsIsn't it the same as in Lova's answer?