[LOGBack-dev] svn commit: r551 - logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Sep 8 19:06:39 CEST 2006
Author: ceki
Date: Fri Sep 8 19:06:38 2006
New Revision: 551
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java
Log:
slightly optimized version
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/MDCConverter.java Fri Sep 8 19:06:38 2006
@@ -5,20 +5,32 @@
import ch.qos.logback.classic.spi.LoggingEvent;
public class MDCConverter extends ClassicConverter {
-
- public MDCConverter() {
- }
-
- @Override
- public String convert(Object event) {
- LoggingEvent loggingEvent = (LoggingEvent)event;
- Map<String, String> mdcPropertyMap = loggingEvent.getMDCPropertyMap();
- if(mdcPropertyMap != null) {
- return loggingEvent.getMDCPropertyMap().get(getFirstOption());
- } else {
- return "";
- }
- }
-}
+ String key;
+
+ public MDCConverter() {
+ }
+ @Override
+ public void start() {
+ key = getFirstOption();
+ super.start();
+ }
+
+ @Override
+ public void stop() {
+ key = null;
+ super.stop();
+ }
+
+ @Override
+ public String convert(Object event) {
+ LoggingEvent loggingEvent = (LoggingEvent) event;
+ Map<String, String> mdcPropertyMap = loggingEvent.getMDCPropertyMap();
+ if (mdcPropertyMap != null) {
+ return loggingEvent.getMDCPropertyMap().get(key);
+ } else {
+ return "";
+ }
+ }
+}
More information about the logback-dev
mailing list