Package org.pipservices3.components.log
Class Logger
java.lang.Object
org.pipservices3.components.log.Logger
- All Implemented Interfaces:
org.pipservices3.commons.config.IConfigurable
,org.pipservices3.commons.config.IReconfigurable
,org.pipservices3.commons.refer.IReferenceable
,ILogger
- Direct Known Subclasses:
CachedLogger
,CompositeLogger
,ConsoleLogger
,DiagnosticsLogger
public abstract class Logger extends Object implements ILogger, org.pipservices3.commons.config.IReconfigurable, org.pipservices3.commons.refer.IReferenceable
Abstract logger that captures and formats log messages.
Child classes take the captured messages and write them to their specific destinations.
### Configuration parameters ###
Parameters to pass to the configure() method for component configuration:
- level: maximum log level to capture
- source: source (context) name
### References ###
- *:context-info:*:*:1.0 (optional)
ContextInfo
to detect the context id and specify counters source
- See Also:
ILogger
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
Logger()
Creates a new instance of the logger. -
Method Summary
Modifier and Type Method Description protected String
composeError(Exception error)
Composes an human-readable error descriptionvoid
configure(org.pipservices3.commons.config.ConfigParams config)
Configures component by passing configuration parameters.void
debug(String correlationId, String message, Object... args)
Logs a high-level debug information for troubleshooting.void
error(String correlationId, Exception error)
Logs recoverable application error.void
error(String correlationId, Exception error, String message, Object... args)
Logs recoverable application error.void
error(String correlationId, String message, Object... args)
Logs recoverable application error.void
fatal(String correlationId, Exception error)
Logs fatal (unrecoverable) message that caused the process to crash.void
fatal(String correlationId, Exception error, String message, Object... args)
Logs fatal (unrecoverable) message that caused the process to crash.void
fatal(String correlationId, String message, Object... args)
Logs fatal (unrecoverable) message that caused the process to crash.protected void
formatAndWrite(LogLevel level, String correlationId, Exception error, String message, Object[] args)
Formats the log message and writes it to the logger destination.LogLevel
getLevel()
Gets the maximum log level.void
info(String correlationId, String message, Object... args)
Logs an important information messagevoid
log(LogLevel level, String correlationId, Exception error, String message, Object... args)
Logs a message at specified log level.void
setLevel(LogLevel value)
Set the maximum log level.void
setReferences(org.pipservices3.commons.refer.IReferences references)
Sets references to dependent components.void
trace(String correlationId, String message, Object... args)
Logs a low-level debug information for troubleshooting.void
warn(String correlationId, String message, Object... args)
Logs a warning that may or may not have a negative impact.protected abstract void
write(LogLevel level, String correlationId, Exception error, String message)
Writes a log message to the logger destination.
-
Field Details
-
_source
-
-
Constructor Details
-
Logger
protected Logger()Creates a new instance of the logger.
-
-
Method Details
-
configure
public void configure(org.pipservices3.commons.config.ConfigParams config)Configures component by passing configuration parameters.- Specified by:
configure
in interfaceorg.pipservices3.commons.config.IConfigurable
- Parameters:
config
- configuration parameters to be set.
-
setReferences
public void setReferences(org.pipservices3.commons.refer.IReferences references)Sets references to dependent components.- Specified by:
setReferences
in interfaceorg.pipservices3.commons.refer.IReferenceable
- Parameters:
references
- references to locate the component dependencies.
-
composeError
Composes an human-readable error description- Parameters:
error
- an error to format.- Returns:
- a human-reable error description.
-
getLevel
Gets the maximum log level. Messages with higher log level are filtered out. -
setLevel
Set the maximum log level. -
write
protected abstract void write(LogLevel level, String correlationId, Exception error, String message)Writes a log message to the logger destination.- Parameters:
level
- a log level.correlationId
- (optional) transaction id to trace execution through call chain.error
- an error object associated with this message.message
- a human-readable message to log.
-
formatAndWrite
protected void formatAndWrite(LogLevel level, String correlationId, Exception error, String message, Object[] args)Formats the log message and writes it to the logger destination.- Parameters:
level
- a log level.correlationId
- (optional) transaction id to trace execution through call chain.error
- an error object associated with this message.message
- a human-readable message to log.args
- arguments to parameterize the message.
-
log
public void log(LogLevel level, String correlationId, Exception error, String message, Object... args)Logs a message at specified log level. -
fatal
Logs fatal (unrecoverable) message that caused the process to crash. -
fatal
Logs fatal (unrecoverable) message that caused the process to crash. -
fatal
Logs fatal (unrecoverable) message that caused the process to crash. -
error
Logs recoverable application error. -
error
Logs recoverable application error. -
error
Logs recoverable application error. -
warn
Logs a warning that may or may not have a negative impact. -
info
Logs an important information message -
debug
Logs a high-level debug information for troubleshooting. -
trace
Logs a low-level debug information for troubleshooting.
-