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
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:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcomposeError(Exception error) Composes an human-readable error descriptionvoidconfigure(org.pipservices3.commons.config.ConfigParams config) Configures component by passing configuration parameters.voidLogs a high-level debug information for troubleshooting.voidLogs recoverable application error.voidLogs recoverable application error.voidLogs recoverable application error.voidLogs fatal (unrecoverable) message that caused the process to crash.voidLogs fatal (unrecoverable) message that caused the process to crash.voidLogs 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.getLevel()Gets the maximum log level.Gets the source (context) name.voidLogs an important information messagevoidLogs a message at specified log level.voidSet the maximum log level.voidsetReferences(org.pipservices3.commons.refer.IReferences references) Sets references to dependent components.voidSets the source (context) name.voidLogs a low-level debug information for troubleshooting.voidLogs a warning that may or may not have a negative impact.protected abstract voidWrites 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.
-
getSource
Gets the source (context) name.- Returns:
- the source (context) name.
-
setSource
Sets the source (context) name.- Parameters:
value- a new source (context) name.
-
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.
-