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, ILoggableTask
Type Parameters
NameDescription
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
TypeNameDescription
ILoggerlogger

Sets the Logger

Fields

DefaultErrorMessageTemplate

The default message template used for logging records of type ETLBoxError.

Declaration
    public const string DefaultErrorMessageTemplate = &quot;Exception in record number {progressCount} at {time}: &#39;{recordAsJson}&#39; - Error details: &#39;{errorText}&#39; (Context: {context}, Source: {source}, Type: {exceptionType})&quot;
Field Value
TypeDescription
string

DefaultMessageTemplate

The default message template used for logging records.

Declaration
    public const string DefaultMessageTemplate = &quot;Record number {progressCount} at {time}: &#39;{recordAsJson}&#39;.&quot;
Field Value
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
Func<TInput, string>

Methods

CheckParameter()

Declaration
    protected override void CheckParameter()
Overrides

CleanUpOnFaulted(Exception)

Declaration
    protected override void CleanUpOnFaulted(Exception e)
Parameters
TypeNameDescription
Exceptione
Overrides

CleanUpOnSuccess()

Declaration
    protected override void CleanUpOnSuccess()
Overrides

InitComponent()

Declaration
    protected override void InitComponent()
Overrides

Implements