log4j 1.2's PatternLayout supports %X{keyname}, but if a keyname is unspecified, Map.get(null) is called which may throw a NullPointerException or at best will return null. log4j 1.3's PatternLayout and extras EnhancedPatternLayout will output all key-value pairs in braces like "{{key1,val1}{key2,val2}}". This patch adds the log4j 1.3/EnhancedPatternLayout behavior, in addition, it sorts the keys alphabetically.
Committed in rev 703285
Curt, is there a reason for the format chosen for %X. I guess I was expecting key=value.
This was a backport of log4j 1.3's (now long abandoned) behavior which predates my involvement with the project. I intentionally mimicked log4j 1.3, but I don't know why that format was used in log4j 1.3.
Ahh, guess I was expecting something like logback does with key=value so I dont have to train log file analysers (e.g. Splunk) on how to interpret the MDC values.