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

Modifier and Type
Method
Description
`void`
`clearMdc()`
Removes all entries from the message diagnostics context.
`void`
`clearNdc()`
Clears the nested diagnostics context.
`Logger`
`getLogger(String name)`
Returns a logger which is backed by a logger from the log provider.
`Object`
`getMdc(String key)`
Returns the value for the key on the message diagnostics context or `null` if no value was found.
`Map<String,Object>`
`getMdcMap()`
Returns the map from the context.
`String`
`getNdc()`
Retrieves the current values set for the nested diagnostics context.
`int`
`getNdcDepth()`
The current depth of the nested diagnostics context.
`String`
`peekNdc()`
Peeks at the top value from the stack and returns it.
`String`
`popNdc()`
Pops top value from the stack and returns it.
`void`
`pushNdc(String message)`
Pushes a value to the nested diagnostics context stack.
`Object`
`putMdc(String key, Object val)`
Puts the value onto the message diagnostics context.
`void`
`removeMdc(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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Log4jLoggerProvider

public Log4jLoggerProvider()

## Method Details

### getLogger

public Logger getLogger(String name)
Description copied from interface: `LoggerProvider`
Returns a logger which is backed by a logger from the log provider.

Note: this should never be `null`

Specified by:
  `getLogger` in interface `LoggerProvider`
Parameters:
  `name` - the name of the logger
Returns:
  a logger for the log provider logger.

### clearMdc

public void clearMdc()
Description copied from interface: `LoggerProvider`
Removes all entries from the message diagnostics context.

Specified by:
  `clearMdc` in interface `LoggerProvider`

### getMdc

public Object getMdc(String key)
Description copied from interface: `LoggerProvider`
Returns the value for the key on the message diagnostics context or `null` if no value was found.

Specified by:
  `getMdc` in interface `LoggerProvider`
Parameters:
  `key` - the key to lookup the value for
Returns:
  the value or `null` if not found

### getMdcMap

public Map<String,Object> getMdcMap()
Description copied from interface: `LoggerProvider`
Returns the map from the context.

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

Specified by:
  `getMdcMap` in interface `LoggerProvider`
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: `LoggerProvider`
Puts the value onto the message diagnostics context.

Specified by:
  `putMdc` in interface `LoggerProvider`
Parameters:
  `key` - the key for the value
  `val` - the value
Returns:
  the previous value set or `null` if no value was set

### removeMdc

public void removeMdc(String key)
Description copied from interface: `LoggerProvider`
Removes the value from the message diagnostics context.

Specified by:
  `removeMdc` in interface `LoggerProvider`
Parameters:
  `key` - the key of the value to remove

### clearNdc

public void clearNdc()
Description copied from interface: `LoggerProvider`
Clears the nested diagnostics context.

Specified by:
  `clearNdc` in interface `LoggerProvider`

### getNdc

public String getNdc()
Description copied from interface: `LoggerProvider`
Retrieves the current values set for the nested diagnostics context.

Specified by:
  `getNdc` in interface `LoggerProvider`
Returns:
  the current value set or `null` if no value was set

### getNdcDepth

public int getNdcDepth()
Description copied from interface: `LoggerProvider`
The current depth of the nested diagnostics context.

Specified by:
  `getNdcDepth` in interface `LoggerProvider`
Returns:
  the current depth of the stack

### peekNdc

public String peekNdc()
Description copied from interface: `LoggerProvider`
Peeks at the top value from the stack and returns it.

Specified by:
  `peekNdc` in interface `LoggerProvider`
Returns:
  the value or an empty string

### popNdc

public String popNdc()
Description copied from interface: `LoggerProvider`
Pops top value from the stack and returns it.

Specified by:
  `popNdc` in interface `LoggerProvider`
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: `LoggerProvider`
Pushes a value to the nested diagnostics context stack.

Specified by:
  `pushNdc` in interface `LoggerProvider`
Parameters:
  `message` - the message to push

### setNdcMaxDepth

public void setNdcMaxDepth(int maxDepth)
Description copied from interface: `LoggerProvider`
Sets maximum depth of the stack removing any entries below the maximum depth.

Specified by:
  `setNdcMaxDepth` in interface `LoggerProvider`
Parameters:
  `maxDepth` - the maximum depth to set