问题
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.
回答1:
Use MEL:
<logger
message="#['Payload is:'+payload+'\nInbound Headers: '+message.inboundProperties.entrySet()+'\nOutbound Headers: '+message.outboundProperties.entrySet()+'\nExceptions: '+exception]"
level="INFO" />
回答2:
You could do something like this:
Payload is: #[payload] #[System.getProperty('line.separator')] Inbound Headers: ...
回答3:
use expression-transformer:
<expression-transformer expression="#[message.payload = message.payload + System.getProperty('line.separator')]" doc:name="Append CRLF"/>
回答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']
回答5:
we can you the below format
#['\n'] #['\n'] #['\n'] #['\n'] #[payload] #[System.getProperty('line.separator')]
回答6:
//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"/>
来源:https://stackoverflow.com/questions/15254304/how-do-you-insert-a-newline-in-message-body-of-mule-logger-component