1 22 package org.jboss.logging.layout; 23 24 import org.apache.log4j.MDC; 25 import org.apache.log4j.helpers.FormattingInfo; 26 import org.apache.log4j.helpers.PatternConverter; 27 import org.apache.log4j.spi.LoggingEvent; 28 29 35 public class ThreadMDCConverter extends PatternConverter 36 { 37 private String key; 38 39 public ThreadMDCConverter(FormattingInfo formattingInfo, String key) 40 { 41 super(formattingInfo); 42 this.key = key; 43 } 44 45 protected String convert(LoggingEvent loggingEvent) 46 { 47 Object val = MDC.get(key); 48 String strVal = null; 49 if( val != null ) 50 strVal = val.toString(); 51 return strVal; 52 } 53 54 } 55 | Popular Tags |