Gary Sharpe
Gary Sharpe

Reputation: 2431

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

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

Answers (8)

Cyril Krr Job
Cyril Krr Job

Reputation: 1

You can use this syntax with Mule 4:

My Input payload: #["\n"] #[payload]

Upvotes: 0

Musheer Alam
Musheer Alam

Reputation: 1

Try this in literal mode. #["\n"] #[ payload]

Upvotes: -1

Sharif
Sharif

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

Lova Chittumuri
Lova Chittumuri

Reputation: 3323

we can you the below format

#['\n'] #['\n']  #['\n'] #['\n']  #[payload] #[System.getProperty('line.separator')]

Upvotes: 1

Ujjawal Kant
Ujjawal Kant

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

Jonathan
Jonathan

Reputation: 43

use expression-transformer:

<expression-transformer expression="#[message.payload = message.payload + System.getProperty('line.separator')]" doc:name="Append CRLF"/>

Upvotes: 2

David Dossot
David Dossot

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

Seba
Seba

Reputation: 2319

You could do something like this:

Payload is: #[payload] #[System.getProperty('line.separator')] Inbound Headers: ...

Upvotes: 6

Related Questions