Top Description Constructors Methods
org.jboss.logging

public final Class Log4jLoggerProvider

extends Object
implements LoggerProvider
Class Inheritance
All Implemented Interfaces
org.jboss.logging.LoggerProvider
Imports
java.util.Collections, .Map, org.apache.log4j.MDC, .NDC

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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
clearMdc()

Implements org.jboss.logging.LoggerProvider.clearMdc.

Removes all entries from the message diagnostics context.

public void
clearNdc()

Implements org.jboss.logging.LoggerProvider.clearNdc.

Clears the nested diagnostics context.

public Logger
getLogger(final String
the name of the logger
name
)

Implements org.jboss.logging.LoggerProvider.getLogger.

Returns a logger which is backed by a logger from the log provider.

public Object
getMdc(String
the key to lookup the value for
key
)

Implements org.jboss.logging.LoggerProvider.getMdc.

Returns the value for the key on the message diagnostics context or null if no value was found.

public Map<String, Object>
getMdcMap()

Implements org.jboss.logging.LoggerProvider.getMdcMap.

Returns the map from the context.

public String
getNdc()

Implements org.jboss.logging.LoggerProvider.getNdc.

Retrieves the current values set for the nested diagnostics context.

public int
getNdcDepth()

Implements org.jboss.logging.LoggerProvider.getNdcDepth.

The current depth of the nested diagnostics context.

public String
peekNdc()

Implements org.jboss.logging.LoggerProvider.peekNdc.

Peeks at the top value from the stack and returns it.

public String
popNdc()

Implements org.jboss.logging.LoggerProvider.popNdc.

Pops top value from the stack and returns it.

public void
pushNdc(String
the message to push
message
)

Implements org.jboss.logging.LoggerProvider.pushNdc.

Pushes a value to the nested diagnostics context stack.

public Object
putMdc(String
the key for the value
key
,
Object
the value
val
)

Implements org.jboss.logging.LoggerProvider.putMdc.

Puts the value onto the message diagnostics context.

public void
removeMdc(String
the key of the value to remove
key
)

Implements org.jboss.logging.LoggerProvider.removeMdc.

Removes the value from the message diagnostics context.

public void
setNdcMaxDepth(int
the maximum depth to set
maxDepth
)

Implements org.jboss.logging.LoggerProvider.setNdcMaxDepth.

Sets maximum depth of the stack removing any entries below the maximum depth.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Log4jLoggerProviderback to summary
public Log4jLoggerProvider()

Method Detail

clearMdcback to summary
public void clearMdc()

Implements org.jboss.logging.LoggerProvider.clearMdc.

Doc from org.jboss.logging.LoggerProvider.clearMdc.

Removes all entries from the message diagnostics context.

Annotations
@Override
clearNdcback to summary
public void clearNdc()

Implements org.jboss.logging.LoggerProvider.clearNdc.

Doc from org.jboss.logging.LoggerProvider.clearNdc.

Clears the nested diagnostics context.

Annotations
@Override
getLoggerback to summary
public Logger getLogger(final String name)

Implements org.jboss.logging.LoggerProvider.getLogger.

Doc from org.jboss.logging.LoggerProvider.getLogger.

Returns a logger which is backed by a logger from the log provider.

Note

this should never be null

Parameters
name:String

the name of the logger

Returns:Logger

a logger for the log provider logger.

Annotations
@Override
getMdcback to summary
public Object getMdc(String key)

Implements org.jboss.logging.LoggerProvider.getMdc.

Doc from org.jboss.logging.LoggerProvider.getMdc.

Returns the value for the key on the message diagnostics context or null if no value was found.

Parameters
key:String

the key to lookup the value for

Returns:Object

the value or null if not found

Annotations
@Override
getMdcMapback to summary
public Map<String, Object> getMdcMap()

Implements org.jboss.logging.LoggerProvider.getMdcMap.

Doc from org.jboss.logging.LoggerProvider.getMdcMap.

Returns the map from the context.

Note that in most implementations this is an expensive operation and should be used sparingly.

Returns:Map<String, Object>

the map from the context or an empty map if the context is null

Annotations
@Override
getNdcback to summary
public String getNdc()

Implements org.jboss.logging.LoggerProvider.getNdc.

Doc from org.jboss.logging.LoggerProvider.getNdc.

Retrieves the current values set for the nested diagnostics context.

Returns:String

the current value set or null if no value was set

Annotations
@Override
getNdcDepthback to summary
public int getNdcDepth()

Implements org.jboss.logging.LoggerProvider.getNdcDepth.

Doc from org.jboss.logging.LoggerProvider.getNdcDepth.

The current depth of the nested diagnostics context.

Returns:int

the current depth of the stack

Annotations
@Override
peekNdcback to summary
public String peekNdc()

Implements org.jboss.logging.LoggerProvider.peekNdc.

Doc from org.jboss.logging.LoggerProvider.peekNdc.

Peeks at the top value from the stack and returns it.

Returns:String

the value or an empty string

Annotations
@Override
popNdcback to summary
public String popNdc()

Implements org.jboss.logging.LoggerProvider.popNdc.

Doc from org.jboss.logging.LoggerProvider.popNdc.

Pops top value from the stack and returns it.

Returns:String

the top value from the stack or an empty string if no value was set

Annotations
@Override
pushNdcback to summary
public void pushNdc(String message)

Implements org.jboss.logging.LoggerProvider.pushNdc.

Doc from org.jboss.logging.LoggerProvider.pushNdc.

Pushes a value to the nested diagnostics context stack.

Parameters
message:String

the message to push

Annotations
@Override
putMdcback to summary
public Object putMdc(String key, Object val)

Implements org.jboss.logging.LoggerProvider.putMdc.

Doc from org.jboss.logging.LoggerProvider.putMdc.

Puts the value onto the message diagnostics context.

Parameters
key:String

the key for the value

val:Object

the value

Returns:Object

the previous value set or null if no value was set

Annotations
@Override
removeMdcback to summary
public void removeMdc(String key)

Implements org.jboss.logging.LoggerProvider.removeMdc.

Doc from org.jboss.logging.LoggerProvider.removeMdc.

Removes the value from the message diagnostics context.

Parameters
key:String

the key of the value to remove

Annotations
@Override
setNdcMaxDepthback to summary
public void setNdcMaxDepth(int maxDepth)

Implements org.jboss.logging.LoggerProvider.setNdcMaxDepth.

Doc from org.jboss.logging.LoggerProvider.setNdcMaxDepth.

Sets maximum depth of the stack removing any entries below the maximum depth.

Parameters
maxDepth:int

the maximum depth to set

Annotations
@Override