1   package org.slf4j.impl;
2   
3   import java.util.Map;
4   
5   import org.slf4j.spi.MDCAdapter;
6   
7   public class Log4jMDCAdapter implements MDCAdapter {
8   
9     public void clear() {
10      Map map = org.apache.log4j.MDC.getContext();
11      if (map != null) {
12        map.clear();
13      }
14    }
15  
16    public String get(String key) {
17      return (String) org.apache.log4j.MDC.get(key);
18    }
19  
20    /**
21     * Put a context value (the <code>val</code> parameter) as identified with
22     * the <code>key</code> parameter into the current thread's context map. The
23     * <code>key</code> parameter cannot be null. Log4j does <em>not</em> 
24     * support null for the <code>val</code> parameter.
25     * 
26     * <p>
27     * This method delegates all work to log4j's MDC.
28     * 
29     * @throws IllegalArgumentException
30     *           in case the "key" or <b>"val"</b> parameter is null
31     */
32    public void put(String key, String val) {
33      org.apache.log4j.MDC.put(key, val);
34    }
35  
36    public void remove(String key) {
37      org.apache.log4j.MDC.remove(key);
38    }
39  
40  }