Class LogDestination<TInput>
A destination that writes each incoming record into a log output using a Microsoft ILogger. Every record is serialized (by default using the same json serialization that is used for the error output) and logged with the defined LogLevel and MessageTemplate. If the input type is ETLBoxError, a specialized default message template and the log level Error are used - this allows to link the error output of any component directly into a LogDestination.
Inherited Members
Namespace: ETLBox.DataFlow
Assembly: ETLBox.dll
Syntax
public class LogDestination<TInput> : DataFlowDestination<TInput>, IDataFlowDestination<TInput>, IDataFlowDestination, IDataFlowComponent, ILoggableTaskType Parameters
| Name | Description |
|---|---|
| TInput | Type of ingoing data. |
Examples
var dest = new LogDestination<MyRow>() { Logger = myLogger };
source.LinkTo(dest);
//Logging the error output of a component:
var errorDest = new LogDestination<ETLBoxError>() { Logger = myLogger };
source.LinkErrorTo(errorDest);Constructors
LogDestination()
Declaration
public LogDestination()LogDestination(ILogger)
Declaration
public LogDestination(ILogger logger)Parameters
| Type | Name | Description |
|---|---|---|
| ILogger | logger | Sets the Logger |
Fields
DefaultErrorMessageTemplate
The default message template used for logging records of type ETLBoxError.
Declaration
public const string DefaultErrorMessageTemplate = "Exception in record number {progressCount} at {time}: '{recordAsJson}' - Error details: '{errorText}' (Context: {context}, Source: {source}, Type: {exceptionType})"Field Value
| Type | Description |
|---|---|
| string |
DefaultMessageTemplate
The default message template used for logging records.
Declaration
public const string DefaultMessageTemplate = "Record number {progressCount} at {time}: '{recordAsJson}'."Field Value
| Type | Description |
|---|---|
| string |
Properties
LogLevel
The log level used when writing a record into the log output. Default is Information, or Error if the incoming record is an ETLBoxError.
Declaration
public LogLevel? LogLevel { get; set; }Property Value
| Type | Description |
|---|---|
| LogLevel? |
Logger
The ILogger instance used for writing the log output. If not set, the LogInstance of the component is used (which defaults to LogInstance).
Declaration
public ILogger Logger { get; set; }Property Value
| Type | Description |
|---|---|
| ILogger |
MessageTemplate
The structured message template used for logging each record. The template receives three arguments: the current record number ({progressCount}), the current time or report time of the error ({time}) and the serialized record ({recordAsJson}). For records of type ETLBoxError, four additional arguments are passed: {errorText}, {context}, {source} and {exceptionType}. If not set, DefaultMessageTemplate is used (or DefaultErrorMessageTemplate for records of type ETLBoxError).
Declaration
public string MessageTemplate { get; set; }Property Value
| Type | Description |
|---|---|
| string |
RecordSerializer
A function that serializes the incoming record into a string. By default, the same json serialization is used that serializes erroneous records for the error output (see ConvertErrorData<T>(T)).
Declaration
public Func<TInput, string> RecordSerializer { get; set; }Property Value
| Type | Description |
|---|---|
| Func<TInput, string> |
Methods
CheckParameter()
Declaration
protected override void CheckParameter()Overrides
CleanUpOnFaulted(Exception)
Declaration
protected override void CleanUpOnFaulted(Exception e)Parameters
| Type | Name | Description |
|---|---|---|
| Exception | e |
Overrides
CleanUpOnSuccess()
Declaration
protected override void CleanUpOnSuccess()Overrides
InitComponent()
Declaration
protected override void InitComponent()