final class Log4jLoggerProvider extends java.lang.Object implements LoggerProvider
Constructor and Description |
---|
Log4jLoggerProvider() |
Modifier and Type | Method and Description |
---|---|
void |
clearMdc()
Removes all entries from the message diagnostics context.
|
void |
clearNdc()
Clears the nested diagnostics context.
|
Logger |
getLogger(java.lang.String name)
Returns a logger which is backed by a logger from the log provider.
|
java.lang.Object |
getMdc(java.lang.String key)
Returns the value for the key on the message diagnostics context or
null if no value was found. |
java.util.Map<java.lang.String,java.lang.Object> |
getMdcMap()
Returns the map from the context.
|
java.lang.String |
getNdc()
Retrieves the current values set for the nested diagnostics context.
|
int |
getNdcDepth()
The current depth of the nested diagnostics context.
|
java.lang.String |
peekNdc()
Peeks at the top value from the stack and returns it.
|
java.lang.String |
popNdc()
Pops top value from the stack and returns it.
|
void |
pushNdc(java.lang.String message)
Pushes a value to the nested diagnostics context stack.
|
java.lang.Object |
putMdc(java.lang.String key,
java.lang.Object val)
Puts the value onto the message diagnostics context.
|
void |
removeMdc(java.lang.String key)
Removes the value from the message diagnostics context.
|
void |
setNdcMaxDepth(int maxDepth)
Sets maximum depth of the stack removing any entries below the maximum depth.
|
public Logger getLogger(java.lang.String name)
LoggerProvider
Note: this should never be null
getLogger
in interface LoggerProvider
name
- the name of the loggerpublic void clearMdc()
LoggerProvider
clearMdc
in interface LoggerProvider
public java.lang.Object getMdc(java.lang.String key)
LoggerProvider
null
if no value was found.getMdc
in interface LoggerProvider
key
- the key to lookup the value fornull
if not foundpublic java.util.Map<java.lang.String,java.lang.Object> getMdcMap()
LoggerProvider
Note that in most implementations this is an expensive operation and should be used sparingly.
getMdcMap
in interface LoggerProvider
null
public java.lang.Object putMdc(java.lang.String key, java.lang.Object val)
LoggerProvider
putMdc
in interface LoggerProvider
key
- the key for the valueval
- the valuenull
if no value was setpublic void removeMdc(java.lang.String key)
LoggerProvider
removeMdc
in interface LoggerProvider
key
- the key of the value to removepublic void clearNdc()
LoggerProvider
clearNdc
in interface LoggerProvider
public java.lang.String getNdc()
LoggerProvider
getNdc
in interface LoggerProvider
null
if no value was setpublic int getNdcDepth()
LoggerProvider
getNdcDepth
in interface LoggerProvider
public java.lang.String peekNdc()
LoggerProvider
peekNdc
in interface LoggerProvider
public java.lang.String popNdc()
LoggerProvider
popNdc
in interface LoggerProvider
public void pushNdc(java.lang.String message)
LoggerProvider
pushNdc
in interface LoggerProvider
message
- the message to pushpublic void setNdcMaxDepth(int maxDepth)
LoggerProvider
setNdcMaxDepth
in interface LoggerProvider
maxDepth
- the maximum depth to set