How to prevent logback/slf4j from parsing a new line character

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-fro... Appreciate any help. Thanks Santosh

String.replace() ?
On 20 Feb 2015, at 00:43, Tadikonda, Santosh <Santosh.Tadikonda@neustar.biz> wrote:
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-fro... <http://stackoverflow.com/questions/28616286/how-to-prevent-logback-slf4j-from-parsing-a-new-line-character>
Appreciate any help.
Thanks Santosh _______________________________________________ Logback-user mailing list Logback-user@qos.ch <mailto:Logback-user@qos.ch> http://mailman.qos.ch/mailman/listinfo/logback-user <http://mailman.qos.ch/mailman/listinfo/logback-user>
participants (2)
-
David Roussel
-
Tadikonda, Santosh