/** * Return a copy of the current thread's context map, with keys and values of * type String. Returned value may be null. * * @return A copy of the current thread's context map. May be null. * @since 1.5.1 */ public static Map<String, String> getCopyOfContextMap() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } return mdcAdapter.getCopyOfContextMap(); }
/** * Put a diagnostic context value (the <code>val</code> parameter) as identified with the * <code>key</code> parameter into the current thread's diagnostic context map. The * <code>key</code> parameter cannot be null. The <code>val</code> parameter * can be null only if the underlying implementation supports it. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key non-null key * @param val value to put in the map * * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void put(String key, String val) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.put(key, val); }
/** * Get the diagnostic context identified by the <code>key</code> parameter. The * <code>key</code> parameter cannot be null. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key * @return the string value identified by the <code>key</code> parameter. * @throws IllegalArgumentException * in case the "key" parameter is null */ public static String get(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } return mdcAdapter.get(key); }
/** * Remove the diagnostic context identified by the <code>key</code> parameter using * the underlying system's MDC implementation. The <code>key</code> parameter * cannot be null. This method does nothing if there is no previous value * associated with <code>key</code>. * * @param key * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void remove(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.remove(key); }
/** * Clear all entries in the MDC of the underlying implementation. */ public static void clear() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.clear(); }
/** * Set the current thread's context map by first clearing any existing map and * then copying the map passed as parameter. The context map passed as * parameter must only contain keys and values of type String. * * @param contextMap * must contain only keys and values of type String * @since 1.5.1 */ public static void setContextMap(Map<String, String> contextMap) { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.setContextMap(contextMap); }
/** * Remove the diagnostic context identified by the <code>key</code> parameter using * the underlying system's MDC implementation. The <code>key</code> parameter * cannot be null. This method does nothing if there is no previous value * associated with <code>key</code>. * * @param key * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void remove(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.remove(key); }
/** * Clear all entries in the MDC of the underlying implementation. */ public static void clear() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.clear(); }
/** * Set the current thread's context map by first clearing any existing map and * then copying the map passed as parameter. The context map passed as * parameter must only contain keys and values of type String. * * @param contextMap * must contain only keys and values of type String * @since 1.5.1 */ public static void setContextMap(Map<String, String> contextMap) { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.setContextMap(contextMap); }
/** * Return a copy of the current thread's context map, with keys and values of * type String. Returned value may be null. * * @return A copy of the current thread's context map. May be null. * @since 1.5.1 */ public static Map<String, String> getCopyOfContextMap() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } return mdcAdapter.getCopyOfContextMap(); }
/** * Put a diagnostic context value (the <code>val</code> parameter) as identified with the * <code>key</code> parameter into the current thread's diagnostic context map. The * <code>key</code> parameter cannot be null. The <code>val</code> parameter * can be null only if the underlying implementation supports it. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key non-null key * @param val value to put in the map * * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void put(String key, String val) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.put(key, val); }
/** * Remove the diagnostic context identified by the <code>key</code> parameter using * the underlying system's MDC implementation. The <code>key</code> parameter * cannot be null. This method does nothing if there is no previous value * associated with <code>key</code>. * * @param key * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void remove(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.remove(key); }
/** * Get the diagnostic context identified by the <code>key</code> parameter. The * <code>key</code> parameter cannot be null. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key * @return the string value identified by the <code>key</code> parameter. * @throws IllegalArgumentException * in case the "key" parameter is null */ public static String get(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } return mdcAdapter.get(key); }
/** * Clear all entries in the MDC of the underlying implementation. */ public static void clear() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.clear(); }
/** * Set the current thread's context map by first clearing any existing map and * then copying the map passed as parameter. The context map passed as * parameter must only contain keys and values of type String. * * @param contextMap * must contain only keys and values of type String * @since 1.5.1 */ public static void setContextMap(Map contextMap) { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.setContextMap(contextMap); }
public Map<String, String> getMDCPropertyMap() { // populate mdcPropertyMap if null if (mdcPropertyMap == null) { MDCAdapter mdc = MDC.getMDCAdapter(); if (mdc instanceof LogbackMDCAdapter) mdcPropertyMap = ((LogbackMDCAdapter) mdc).getPropertyMap(); else mdcPropertyMap = mdc.getCopyOfContextMap(); } // mdcPropertyMap still null, use emptyMap() if (mdcPropertyMap == null) mdcPropertyMap = Collections.emptyMap(); return mdcPropertyMap; }
/** * Put a diagnostic context value (the <code>val</code> parameter) as identified with the * <code>key</code> parameter into the current thread's diagnostic context map. The * <code>key</code> parameter cannot be null. The <code>val</code> parameter * can be null only if the underlying implementation supports it. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key non-null key * @param val value to put in the map * * @throws IllegalArgumentException * in case the "key" parameter is null */ public static void put(String key, String val) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.put(key, val); }
@Override public void remove(String key) { _delegate.remove(key); }
/** * Get the diagnostic context identified by the <code>key</code> parameter. The * <code>key</code> parameter cannot be null. * * <p> * This method delegates all work to the MDC of the underlying logging system. * * @param key * @return the string value identified by the <code>key</code> parameter. * @throws IllegalArgumentException * in case the "key" parameter is null */ public static String get(String key) throws IllegalArgumentException { if (key == null) { throw new IllegalArgumentException("key parameter cannot be null"); } if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } return mdcAdapter.get(key); }
/** * Clear all entries in the MDC of the underlying implementation. */ public static void clear() { if (mdcAdapter == null) { throw new IllegalStateException("MDCAdapter cannot be null. See also " + NULL_MDCA_URL); } mdcAdapter.clear(); }