解决方法
这可以在
Logback,Log4J的继承者中完成.
Logback is intended as a successor to the popular log4j project,picking up where log4j leaves off.
请参阅Sifting Appender的文档
The SiftingAppender is unique in its capacity to reference and configure nested appenders. In the above example,within the SiftingAppender there will be nested FileAppender instances,each instance identified by the value associated with the “userid” MDC key. Whenever the “userid” MDC key is assigned a new value,a new FileAppender instance will be built from scratch. The SiftingAppender keeps track of the appenders it creates. Appenders unused for 30 minutes will be automatically closed and discarded.