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)
ContextInfoto detect the context id and specify counters source
- See Also:
ILogger
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedLogger()Creates a new instance of the logger. -
Method Summary
Modifier and Type Method Description protected StringcomposeError(Exception error)Composes an human-readable error descriptionvoidconfigure(org.pipservices3.commons.config.ConfigParams config)Configures component by passing configuration parameters.voiddebug(String correlationId, String message, Object... args)Logs a high-level debug information for troubleshooting.voiderror(String correlationId, Exception error)Logs recoverable application error.voiderror(String correlationId, Exception error, String message, Object... args)Logs recoverable application error.voiderror(String correlationId, String message, Object... args)Logs recoverable application error.voidfatal(String correlationId, Exception error)Logs fatal (unrecoverable) message that caused the process to crash.voidfatal(String correlationId, Exception error, String message, Object... args)Logs fatal (unrecoverable) message that caused the process to crash.voidfatal(String correlationId, String message, Object... args)Logs fatal (unrecoverable) message that caused the process to crash.protected voidformatAndWrite(LogLevel level, String correlationId, Exception error, String message, Object[] args)Formats the log message and writes it to the logger destination.LogLevelgetLevel()Gets the maximum log level.voidinfo(String correlationId, String message, Object... args)Logs an important information messagevoidlog(LogLevel level, String correlationId, Exception error, String message, Object... args)Logs a message at specified log level.voidsetLevel(LogLevel value)Set the maximum log level.voidsetReferences(org.pipservices3.commons.refer.IReferences references)Sets references to dependent components.voidtrace(String correlationId, String message, Object... args)Logs a low-level debug information for troubleshooting.voidwarn(String correlationId, String message, Object... args)Logs a warning that may or may not have a negative impact.protected abstract voidwrite(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:
configurein 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:
setReferencesin 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.
-