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.
Use MEL:
<logger
message="#['Payload is:'+payload+'\nInbound Headers: '+message.inboundProperties.entrySet()+'\nOutbound Headers: '+message.outboundProperties.entrySet()+'\nExceptions: '+exception]"
level="INFO" />
你可以这样做:
Payload is: #[payload] #[System.getProperty('line.separator')] Inbound Headers: ...
使用表达式转换器:
<expression-transformer expression="#[message.payload = message.payload + System.getProperty('line.separator')]" doc:name="Append CRLF"/>
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']
我们可以为您提供以下格式
#['\n'] #['\n'] #['\n'] #['\n'] #[payload] #[System.getProperty('line.separator')]
//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"/>
You can use this syntax with Mule 4:
My Input payload: #["\n"] #[payload]
Try this in literal mode. #["\n"] #[ payload]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.