Affects Version/s: 2.0-rc1
Fix Version/s: None
I upgraded a log4j 1.2 layout pattern containing "\t" to log4j 2:
The resulting output contained "\t" instead of the expected tab character.
It seems the old DOMConfigurator applied OptionConverter.convertSpecialChars to the "value" attribute of every "param" element.
We can't convert special characters quite as broadly anymore because it would break things like the "%replace" pattern. I considered various conversion points including the PatternLayout constructor, in XmlConfiguration.processAttributes, or in AbstractPluginVisitor.convert.
In fact, PatternLayout.setConversionPattern actually did convertSpecialChars even though the constructor did not.
It seems the best place to replace the 'special chars' is now in LiteralPatternConverter (see my patch). I added a test to PatternLayoutTest to demonstrate.
I studied all the other plugin attributes and couldn't find any others where special characters might be useful, except perhaps the ColumnConfig "pattern" attribute, which happens to use PatternLayout so it now supports the special character escapes as well.
Side note: PatternLayout.setConversionPattern was not storing the new value in the conversionPattern field since it was final. I've made it non-final (see patch) so we can store it there, just in case anyone ever calls getConversionPattern (not likely).
|Summary||Special characters (tab) in PatternLayout||Special characters (tab and so on) in PatternLayout do not work|
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Resolution||Fixed [ 1 ]|
|Status||Resolved [ 5 ]||Closed [ 6 ]|
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|2h 51m||1||Gary Gregory||25/Jun/14 14:58|
|2h 14m||1||Scott Harrington||25/Jun/14 17:12|