com.atlassian.confluence.util.logging
Class LoggingContext

java.lang.Object
  extended by com.atlassian.confluence.util.logging.LoggingContext

public final class LoggingContext
extends java.lang.Object

Manages contextual information in the Log4J Mapped Diagnostic Context.

Since:
3.5
See Also:
PatternLayoutWithContext, LoggingContextFilter, MDC

Method Summary
static void clear()
          Removes all keys from the logging context which are managed by this class.
static void clearAll()
          Clears all MDC information on the current thread.
static java.util.Map<java.lang.String,java.lang.Object> getContext()
          Returns an immutable copy of the underlying logging context map.
static java.lang.String getUserName()
          Returns the currently mapped 'userName' value from the context, or null if none has been set.
static boolean isEmpty()
          Returns true if the logging context has been initialised and has data in it, otherwise false.
static void put(java.lang.String key, java.lang.String value)
          Sets the value associated with the key in the logging context, overwriting any existing value.
static void remove(java.lang.String... keys)
          Removes any value associated with the keys in the logging context.
static void setReferer(java.lang.String referer)
          Sets the 'referer' value in the logging context.
static void setUrl(java.lang.String url)
          Sets the 'url' value in the logging context.
static void setUserName(java.lang.String userName)
          Sets the 'userName' value in the logging context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setUrl

public static void setUrl(java.lang.String url)
Sets the 'url' value in the logging context. Does nothing if url is null.


setUserName

public static void setUserName(java.lang.String userName)
Sets the 'userName' value in the logging context. Sets it to 'anonymous' if userName is null.


getUserName

public static java.lang.String getUserName()
Returns the currently mapped 'userName' value from the context, or null if none has been set.


setReferer

public static void setReferer(java.lang.String referer)
Sets the 'referer' value in the logging context. Does nothing if referer is null.


put

public static void put(java.lang.String key,
                       java.lang.String value)
Sets the value associated with the key in the logging context, overwriting any existing value.

Code which calls to this method should remove the context information by calling remove(java.lang.String...) with the same key in a finally block.

See Also:
MDC.put(java.lang.String, java.lang.Object)

remove

public static void remove(java.lang.String... keys)
Removes any value associated with the keys in the logging context.


isEmpty

public static boolean isEmpty()
Returns true if the logging context has been initialised and has data in it, otherwise false.


getContext

public static java.util.Map<java.lang.String,java.lang.Object> getContext()
Returns an immutable copy of the underlying logging context map.


clear

public static void clear()
Removes all keys from the logging context which are managed by this class. Anything which has been added by a call to put(java.lang.String, java.lang.String) needs to be removed by calling remove(java.lang.String...) with the same key.


clearAll

public static void clearAll()
Clears all MDC information on the current thread. Normally used to clear nested MDC information on a new thread.



Copyright © 2003-2014 Atlassian. All Rights Reserved.