Top Description Fields Constructors Methods
org.apache.logging.log4j.simple

public Class SimpleLoggerContext

extends Object
implements LoggerContext
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.spi.LoggerContext
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, java.io.FileNotFoundException, .FileOutputStream, .PrintStream, org.apache.logging.log4j.Level, org.apache.logging.log4j.message.MessageFactory, org.apache.logging.log4j.spi.AbstractLogger, .ExtendedLogger, .LoggerContext, .LoggerRegistry, org.apache.logging.log4j.util.PropertiesUtil

A simple LoggerContext implementation.

Field Summary

Modifier and TypeField and Description
private final String
dateTimeFormat

The date and time format to use in the log message

protected static final String
DEFAULT_DATE_TIME_FORMAT

The default format to use when formatting dates

private final Level
pack-priv static final SimpleLoggerContext
INSTANCE

Singleton instance.

private final LoggerRegistry<ExtendedLogger>
private final PropertiesUtil
private final boolean
showContextMap

Include the ThreadContextMap in the log message

private final boolean
showDateTime

Include the current time in the log message

private final boolean
showLogName

Include the instance name in the log message?

private final boolean
showShortName

Include the short name (last component) of the logger in the log message.

private final PrintStream
private static final String
private static final String
protected static final String
SYSTEM_PREFIX

All system properties used by SimpleLog start with this

Constructor Summary

AccessConstructor and Description
public
SimpleLoggerContext()

Constructs a new initialized instance.

Method Summary

Modifier and TypeMethod and Description
public Object
getExternalContext()

Implements org.apache.logging.log4j.spi.LoggerContext.getExternalContext.

Gets the anchor for some other context, such as a ClassLoader or ServletContext.

public ExtendedLogger
getLogger(final String
The name of the Logger to return.
name
)

Implements org.apache.logging.log4j.spi.LoggerContext.getLogger.

Gets an ExtendedLogger.

public ExtendedLogger
getLogger(final String
The name of the Logger to return.
name
,
final MessageFactory
The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.
messageFactory
)

Implements org.apache.logging.log4j.spi.LoggerContext.getLogger.

Gets an ExtendedLogger.

public LoggerRegistry<ExtendedLogger>

Returns:

the LoggerRegistry.
getLoggerRegistry
()

Overrides default org.apache.logging.log4j.spi.LoggerContext.getLoggerRegistry.

Gets the LoggerRegistry.

public boolean
hasLogger(final String
The Logger name to search for.
name
)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name exists.

public boolean
hasLogger(final String
The Logger name to search for.
name
,
final Class<? extends MessageFactory>
The message factory class to search for.
messageFactoryClass
)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name and MessageFactory type exists.

public boolean
hasLogger(final String
The Logger name to search for.
name
,
final MessageFactory
The message factory to search for.
messageFactory
)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name and MessageFactory exists.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dateTimeFormatback to summary
private final String dateTimeFormat

The date and time format to use in the log message

DEFAULT_DATE_TIME_FORMATback to summary
protected static final String DEFAULT_DATE_TIME_FORMAT

The default format to use when formatting dates

defaultLevelback to summary
private final Level defaultLevel
INSTANCEback to summary
pack-priv static final SimpleLoggerContext INSTANCE

Singleton instance.

loggerRegistryback to summary
private final LoggerRegistry<ExtendedLogger> loggerRegistry
propsback to summary
private final PropertiesUtil props
showContextMapback to summary
private final boolean showContextMap

Include the ThreadContextMap in the log message

showDateTimeback to summary
private final boolean showDateTime

Include the current time in the log message

showLogNameback to summary
private final boolean showLogName

Include the instance name in the log message?

showShortNameback to summary
private final boolean showShortName

Include the short name (last component) of the logger in the log message. Defaults to true - otherwise we'll be lost in a flood of messages without knowing who sends them.

streamback to summary
private final PrintStream stream
SYSTEM_ERRback to summary
private static final String SYSTEM_ERR
SYSTEM_OUTback to summary
private static final String SYSTEM_OUT
SYSTEM_PREFIXback to summary
protected static final String SYSTEM_PREFIX

All system properties used by SimpleLog start with this

Constructor Detail

SimpleLoggerContextback to summary
public SimpleLoggerContext()

Constructs a new initialized instance.

Annotations
@SuppressFBWarnings:PATH_TRAVERSAL_OUT
justification:Opens a file retrieved from configuration (Log4j properties)

Method Detail

getExternalContextback to summary
public Object getExternalContext()

Implements org.apache.logging.log4j.spi.LoggerContext.getExternalContext.

Doc from org.apache.logging.log4j.spi.LoggerContext.getExternalContext.

Gets the anchor for some other context, such as a ClassLoader or ServletContext.

Returns:Object

The external context.

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

Implements org.apache.logging.log4j.spi.LoggerContext.getLogger.

Doc from org.apache.logging.log4j.spi.LoggerContext.getLogger.

Gets an ExtendedLogger.

Parameters
name:String

The name of the Logger to return.

Returns:ExtendedLogger

The logger with the specified name.

Annotations
@Override
getLoggerback to summary
public ExtendedLogger getLogger(final String name, final MessageFactory messageFactory)

Implements org.apache.logging.log4j.spi.LoggerContext.getLogger.

Doc from org.apache.logging.log4j.spi.LoggerContext.getLogger.

Gets an ExtendedLogger.

Parameters
name:String

The name of the Logger to return.

messageFactory:MessageFactory

The message factory is used only when creating a logger, subsequent use does not change the logger but will log a warning if mismatched.

Returns:ExtendedLogger

The logger with the specified name.

Annotations
@Override
getLoggerRegistryback to summary
public LoggerRegistry<ExtendedLogger> getLoggerRegistry()

Overrides default org.apache.logging.log4j.spi.LoggerContext.getLoggerRegistry.

Gets the LoggerRegistry.

Returns:LoggerRegistry<ExtendedLogger>

the LoggerRegistry.

Annotations
@Override
Since
2.17.2
hasLoggerback to summary
public boolean hasLogger(final String name)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Doc from org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name exists.

Parameters
name:String

The Logger name to search for.

Returns:boolean

true if the Logger exists, false otherwise.

Annotations
@Override
hasLoggerback to summary
public boolean hasLogger(final String name, final Class<? extends MessageFactory> messageFactoryClass)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Doc from org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name and MessageFactory type exists.

Parameters
name:String

The Logger name to search for.

messageFactoryClass:Class<? extends MessageFactory>

The message factory class to search for.

Returns:boolean

true if the Logger exists, false otherwise.

Annotations
@Override
hasLoggerback to summary
public boolean hasLogger(final String name, final MessageFactory messageFactory)

Implements org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Doc from org.apache.logging.log4j.spi.LoggerContext.hasLogger.

Tests if a Logger with the specified name and MessageFactory exists.

Parameters
name:String

The Logger name to search for.

messageFactory:MessageFactory

The message factory to search for.

Returns:boolean

true if the Logger exists, false otherwise.

Annotations
@Override