java.lang.Object
org.tentackle.log.log4j2v.Log4J2Logger
- All Implemented Interfaces:
Logger
Pluggable logger using
org.apache.log4j
.
Logger wrapper for Log4J version 2.
- Author:
- harald
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.tentackle.log.Logger
Logger.Level
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doLog
(Logger.Level level, String message, Throwable cause, Object... params) Logging workhorse.protected void
doLog
(Logger.Level level, Throwable cause, String message, Supplier<?>... paramSuppliers) Logging workhorse.protected void
Logging workhorse.void
Logs a message with level FINE.void
Logs a message with level FINE.void
Logs a message with level FINE.void
Logs a message with level FINE.void
Logs a message with level FINE.void
Logs a message with level FINE.void
Logs a message with level FINER.void
Logs a message with level FINER.void
Logs a message with level FINER.void
Logs a message with level FINER.void
Logs a message with level FINER.void
Logs a message with level FINER.static Log4J2Logger
Gets the Log4J2Logger for given name.Gets the concrete logger implementation.
Useful to access the logging-backend.Gets the MDC.
Usually a singleton (depending on the backend).void
Logs a message with level INFO.void
Logs a message with level INFO.void
Logs a message with level INFO.void
Logs a message with level INFO.void
Logs a message with level INFO.void
Logs a message with level INFO.boolean
Checks if logger logs level FINE.boolean
Checks if logger logs level FINER.boolean
Checks if logger logs level INFO.boolean
isLoggable
(Logger.Level level) Checks if a message of the given level would actually be logged by this logger.boolean
Checks if logger logs level SEVERE.boolean
Checks if logger logs level WARNING.void
log
(Logger.Level level, String message, Throwable cause) Logs a message.void
log
(Logger.Level level, Throwable cause, Supplier<String> messageSupplier) Logs a message.void
logStacktrace
(Throwable cause) Logs the stacktrace of a throwable with a logging level of SEVERE.void
logStacktrace
(Logger.Level level, Throwable cause) Logs the stacktrace of a throwable.void
Logs a message with level SEVERE.void
Logs a message with level SEVERE.void
Logs a message with level SEVERE.void
Logs a message with level SEVERE.void
Logs a message with level SEVERE.void
Logs a message with level SEVERE.void
Logs a message with level WARNING.void
Logs a message with level WARNING.void
Logs a message with level WARNING.void
Logs a message with level WARNING.void
Logs a message with level WARNING.void
Logs a message with level WARNING.
-
Constructor Details
-
Log4J2Logger
Creates a logger.- Parameters:
name
- the name of the logger
-
-
Method Details
-
getLogger
Gets the Log4J2Logger for given name. If a logger with that name already exists, it will be re-used.- Parameters:
name
- the name of the logger- Returns:
- the logger
-
getLoggerImpl
Description copied from interface:Logger
Gets the concrete logger implementation.
Useful to access the logging-backend.- Specified by:
getLoggerImpl
in interfaceLogger
- Returns:
- the logger object
-
isLoggable
Description copied from interface:Logger
Checks if a message of the given level would actually be logged by this logger.- Specified by:
isLoggable
in interfaceLogger
- Parameters:
level
- the logging level- Returns:
- true if the given logging level is currently being logged
-
log
Description copied from interface:Logger
Logs a message. -
log
Description copied from interface:Logger
Logs a message. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
finer
Description copied from interface:Logger
Logs a message with level FINER. -
fine
Description copied from interface:Logger
Logs a message with level FINE. -
info
Description copied from interface:Logger
Logs a message with level INFO. -
warning
Description copied from interface:Logger
Logs a message with level WARNING. -
severe
Description copied from interface:Logger
Logs a message with level SEVERE. -
isFinerLoggable
public boolean isFinerLoggable()Description copied from interface:Logger
Checks if logger logs level FINER.- Specified by:
isFinerLoggable
in interfaceLogger
- Returns:
- true if logger will log this level
-
isFineLoggable
public boolean isFineLoggable()Description copied from interface:Logger
Checks if logger logs level FINE.- Specified by:
isFineLoggable
in interfaceLogger
- Returns:
- true if logger will log this level
-
isInfoLoggable
public boolean isInfoLoggable()Description copied from interface:Logger
Checks if logger logs level INFO.- Specified by:
isInfoLoggable
in interfaceLogger
- Returns:
- true if logger will log this level
-
isWarningLoggable
public boolean isWarningLoggable()Description copied from interface:Logger
Checks if logger logs level WARNING.- Specified by:
isWarningLoggable
in interfaceLogger
- Returns:
- true if logger will log this level
-
isSevereLoggable
public boolean isSevereLoggable()Description copied from interface:Logger
Checks if logger logs level SEVERE.- Specified by:
isSevereLoggable
in interfaceLogger
- Returns:
- true if logger will log this level
-
logStacktrace
Logs the stacktrace of a throwable.- Specified by:
logStacktrace
in interfaceLogger
- Parameters:
level
- the logging levelcause
- the Throwable to log the stacktrace for
-
logStacktrace
Logs the stacktrace of a throwable with a logging level of SEVERE.- Specified by:
logStacktrace
in interfaceLogger
- Parameters:
cause
- the Throwable to log the stacktrace for
-
getMappedDiagnosticContext
Description copied from interface:Logger
Gets the MDC.
Usually a singleton (depending on the backend).- Specified by:
getMappedDiagnosticContext
in interfaceLogger
- Returns:
- the MDC
-
doLog
Logging workhorse.- Parameters:
level
- the log levelmessage
- the messagecause
- the causeparams
- optional parameters
-
doLog
protected void doLog(Logger.Level level, Throwable cause, String message, Supplier<?>... paramSuppliers) Logging workhorse.- Parameters:
level
- the log levelcause
- the causemessage
- the messageparamSuppliers
- parameter suppliers
-
doLog
protected void doLog(Logger.Level level, Throwable cause, String message, Supplier<String> messageSupplier) Logging workhorse.- Parameters:
level
- the log levelcause
- the cause, null if nonemessage
- the message, null if messageSuppliermessageSupplier
- the message supplier, null if message
-