Package org.jboss.logging
Class Log4jLoggerProvider
- java.lang.Object
-
- org.jboss.logging.Log4jLoggerProvider
-
- All Implemented Interfaces:
LoggerProvider
public final class Log4jLoggerProvider extends Object implements LoggerProvider
An implementation of the log provider for log4j.Please note that log4j reached end of life on August 5, 2015. Prefer using a log manager and provider.
-
-
Constructor Summary
Constructors Constructor Description Log4jLoggerProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearMdc()Removes all entries from the message diagnostics context.voidclearNdc()Clears the nested diagnostics context.LoggergetLogger(String name)Returns a logger which is backed by a logger from the log provider.ObjectgetMdc(String key)Returns the value for the key on the message diagnostics context ornullif no value was found.Map<String,Object>getMdcMap()Returns the map from the context.StringgetNdc()Retrieves the current values set for the nested diagnostics context.intgetNdcDepth()The current depth of the nested diagnostics context.StringpeekNdc()Peeks at the top value from the stack and returns it.StringpopNdc()Pops top value from the stack and returns it.voidpushNdc(String message)Pushes a value to the nested diagnostics context stack.ObjectputMdc(String key, Object val)Puts the value onto the message diagnostics context.voidremoveMdc(String key)Removes the value from the message diagnostics context.voidsetNdcMaxDepth(int maxDepth)Sets maximum depth of the stack removing any entries below the maximum depth.
-
-
-
Method Detail
-
getLogger
public Logger getLogger(String name)
Description copied from interface:LoggerProviderReturns a logger which is backed by a logger from the log provider.Note: this should never be
null- Specified by:
getLoggerin interfaceLoggerProvider- Parameters:
name- the name of the logger- Returns:
- a logger for the log provider logger.
-
clearMdc
public void clearMdc()
Description copied from interface:LoggerProviderRemoves all entries from the message diagnostics context.- Specified by:
clearMdcin interfaceLoggerProvider
-
getMdc
public Object getMdc(String key)
Description copied from interface:LoggerProviderReturns the value for the key on the message diagnostics context ornullif no value was found.- Specified by:
getMdcin interfaceLoggerProvider- Parameters:
key- the key to lookup the value for- Returns:
- the value or
nullif not found
-
getMdcMap
public Map<String,Object> getMdcMap()
Description copied from interface:LoggerProviderReturns the map from the context.Note that in most implementations this is an expensive operation and should be used sparingly.
- Specified by:
getMdcMapin interfaceLoggerProvider- Returns:
- the map from the context or an empty map if the context is
null
-
putMdc
public Object putMdc(String key, Object val)
Description copied from interface:LoggerProviderPuts the value onto the message diagnostics context.- Specified by:
putMdcin interfaceLoggerProvider- Parameters:
key- the key for the valueval- the value- Returns:
- the previous value set or
nullif no value was set
-
removeMdc
public void removeMdc(String key)
Description copied from interface:LoggerProviderRemoves the value from the message diagnostics context.- Specified by:
removeMdcin interfaceLoggerProvider- Parameters:
key- the key of the value to remove
-
clearNdc
public void clearNdc()
Description copied from interface:LoggerProviderClears the nested diagnostics context.- Specified by:
clearNdcin interfaceLoggerProvider
-
getNdc
public String getNdc()
Description copied from interface:LoggerProviderRetrieves the current values set for the nested diagnostics context.- Specified by:
getNdcin interfaceLoggerProvider- Returns:
- the current value set or
nullif no value was set
-
getNdcDepth
public int getNdcDepth()
Description copied from interface:LoggerProviderThe current depth of the nested diagnostics context.- Specified by:
getNdcDepthin interfaceLoggerProvider- Returns:
- the current depth of the stack
-
peekNdc
public String peekNdc()
Description copied from interface:LoggerProviderPeeks at the top value from the stack and returns it.- Specified by:
peekNdcin interfaceLoggerProvider- Returns:
- the value or an empty string
-
popNdc
public String popNdc()
Description copied from interface:LoggerProviderPops top value from the stack and returns it.- Specified by:
popNdcin interfaceLoggerProvider- Returns:
- the top value from the stack or an empty string if no value was set
-
pushNdc
public void pushNdc(String message)
Description copied from interface:LoggerProviderPushes a value to the nested diagnostics context stack.- Specified by:
pushNdcin interfaceLoggerProvider- Parameters:
message- the message to push
-
setNdcMaxDepth
public void setNdcMaxDepth(int maxDepth)
Description copied from interface:LoggerProviderSets maximum depth of the stack removing any entries below the maximum depth.- Specified by:
setNdcMaxDepthin interfaceLoggerProvider- Parameters:
maxDepth- the maximum depth to set
-
-