Just a quick note: this combination does not work!
The JVM switch -XX:+UseStringCache doesn't play nicely with log4j MDC logging. According to the JVM docs "Enables caching of commonly allocated strings.". But it makes the MDC values simply vanish from the logs.
It also caused distorsions in the log messages themselves. For example, I started seeing the literal "nse=HTTP/1.1 200" randomly pop up at the end of my log statements. Very strange. I assume it has to do with memory pointers or the like.
Take into account that HotSpot JVM -XX options are defined as experimental by nature, so be careful when you play with them.