/** * Clears the nested diagnostics context. */ public static void clear() { LoggerProviders.PROVIDER.clearNdc(); }
/** * Get a Logger instance given the logger name. * * @param name the logger name * * @return the logger */ public static Logger getLogger(String name) { return LoggerProviders.PROVIDER.getLogger(name); }
/** * Returns the value for the key or {@code null} if no value was found. * * @param key the key to lookup the value for * * @return the value or {@code null} if not found */ public static Object get(String key) { return LoggerProviders.PROVIDER.getMdc(key); }
/** * Pops top value from the stack and returns it. * * @return the top value from the stack or an empty string if no value was set */ public static String pop() { return LoggerProviders.PROVIDER.popNdc(); }
/** * Puts the value onto the context. * * @param key the key for the value * @param val the value * * @return the previous value set or {@code null} if no value was set */ public static Object put(String key, Object val) { return LoggerProviders.PROVIDER.putMdc(key, val); }
/** * Retrieves the current values set for the nested diagnostics context. * * @return the current value set or {@code null} if no value was set */ public static String get() { return LoggerProviders.PROVIDER.getNdc(); }
/** * The current depth of the nested diagnostics context. * * @return the current depth of the stack */ public static int getDepth() { return LoggerProviders.PROVIDER.getNdcDepth(); }
/** * Peeks at the top value from the stack and returns it. * * @return the value or an empty string */ public static String peek() { return LoggerProviders.PROVIDER.peekNdc(); }
/** * Pushes a value to the nested diagnostics context stack. * * @param message the message to push */ public static void push(String message) { LoggerProviders.PROVIDER.pushNdc(message); }
/** * Returns the map from the context. * * <p> * Note that in most implementations this is an expensive operation and should be used sparingly. * </p> * * @return the map from the context or an {@linkplain Collections#emptyMap() empty map} if the context is {@code * null} */ public static Map<String, Object> getMap() { return LoggerProviders.PROVIDER.getMdcMap(); }
/** * Pops top value from the stack and returns it. * * @return the top value from the stack or an empty string if no value was set */ public static String pop() { return LoggerProviders.PROVIDER.popNdc(); }
/** * Puts the value onto the context. * * @param key the key for the value * @param val the value * * @return the previous value set or {@code null} if no value was set */ public static Object put(String key, Object val) { return LoggerProviders.PROVIDER.putMdc(key, val); }
/** * Retrieves the current values set for the nested diagnostics context. * * @return the current value set or {@code null} if no value was set */ public static String get() { return LoggerProviders.PROVIDER.getNdc(); }
/** * The current depth of the nested diagnostics context. * * @return the current depth of the stack */ public static int getDepth() { return LoggerProviders.PROVIDER.getNdcDepth(); }
/** * Peeks at the top value from the stack and returns it. * * @return the value or an empty string */ public static String peek() { return LoggerProviders.PROVIDER.peekNdc(); }
/** * Pushes a value to the nested diagnostics context stack. * * @param message the message to push */ public static void push(String message) { LoggerProviders.PROVIDER.pushNdc(message); }
public static Map<String, Object> getMap() { return LoggerProviders.PROVIDER.getMdcMap(); } }
/** * Pops top value from the stack and returns it. * * @return the top value from the stack or an empty string if no value was set */ public static String pop() { return LoggerProviders.PROVIDER.popNdc(); }
/** * Puts the value onto the context. * * @param key the key for the value * @param val the value * * @return the previous value set or {@code null} if no value was set */ public static Object put(String key, Object val) { return LoggerProviders.PROVIDER.putMdc(key, val); }
private static void logProvider(final LoggerProvider provider, final String via) { // Log a debug message indicating which logger we are using final Logger logger = provider.getLogger(LoggerProviders.class.getPackage().getName()); if (via == null) { logger.debugf("Logging Provider: %s", provider.getClass().getName()); } else { logger.debugf("Logging Provider: %s found via %s", provider.getClass().getName(), via); } }