Logger that writes log messages to console.
Extends: Logger
Description
The ConsoleLogger class provides a logger that writes log messages to console.
Important points
- Errors are written to the standard err stream and all other messages to the standard out stream.
Configuration parameters
- level: maximum log level to capture
- source: source (context)’s name
References
- *:context-info:*:*:1.0 - (optional) ContextInfo to detect the context id and specify counters source
Constructors
Creates a new instance of the logger.
ConsoleLogger()
Instance methods
write
Writes a log message to the logger destination.
void write(LogLevel level, IContext? context, Exception? error, String message)
- level: LogLevel - a log level.
- context: IContext - (optional) a context to trace execution through a call chain.
- error: Exception? - error object associated with this message.
- message: String - human-readable message to log.
Examples
var logger = new ConsoleLogger();
logger.setLevel(LogLevel.debug);
logger.error('123', ex, 'Error occured: %s', ex.message);
logger.debug('123', 'Everything is OK.');