[logback-user] How to prevent logback/slf4j from parsing a new line character

Tadikonda, Santosh Santosh.Tadikonda at neustar.biz
Fri Feb 20 01:43:07 CET 2015


I'm using logback with SLF4j for logging in my application. I have a string that contains a new line character. It is part of the string value but doesn't signify a new line. When I print the string, logback prints it in a new line. How to prevent this ?
Code:
String str = "george\nmason"
logger.info(str);
Logback pattern:
<pattern>[%d{dd MMM yyyy HH:mm:ss,SSS}] [%5p] [%X{sid}] [%-20C{0} %25M]:[%-4L] - %m%n</pattern>
Expected:
[19 Feb 2015 20:19:27] [ INFO] [] [myClass myMethod]:[52  ] - george\nmason
Actual Output:
[19 Feb 2015 20:19:27] [ INFO] [] [myClass myMethod]:[52  ] - george
mason

http://stackoverflow.com/questions/28616286/how-to-prevent-logback-slf4j-from-parsing-a-new-line-character

Appreciate any help.

Thanks
Santosh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20150220/531217c8/attachment.html>


More information about the Logback-user mailing list