How do you insert a newline in message body of mule logger component

偶尔善良 提交于 2020-01-01 08:52:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!