Can you provide a unit test?
The following unit test passes for me.
PatternLayout pl = new PatternLayout(); LoggerContext lc = new LoggerContext(); pl.setContext(lc); pl.setPattern("%replace(A\nB){'\n', '\n\t'}"); pl.start(); String val = pl.doLayout(makeLoggingEvent("", null)); assertEquals("A\n\tB", val);
For the exact code see replaceNewLine() method