Skip to main content

Logging

Version: 3.0

Converter Logging

The DynamicPDF Converter for .NET supports logging through the ConversionOptions class's static Logging property. Specify the logging level and filepath to set the logging configuration globally for your application.

Logging Level​

Logging LevelDescription
LogLevel.Complete5Every log statement is logged.
LogLevel.Debug4Full Debug information is logged.
LogLevel.Error1Only errors are logged.
LogLevel.Information3Useful information, along with warnings and errors is logged.
LogLevel.None0No logging.
LogLevel.Warning2Warnings and errors are logged.

Example​

ConversionOptions.Logging.Level = LogLevel.Debug;
ConversionOptions.Logging.LogFilePath = logOutputPath;
ConversionOptions.Logging.Level = LogLevel.Debug
ConversionOptions.Logging.LogFilePath = logOutputPath

[LoggingExample.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/LoggingExample.cs){#gitlink-id target=_blank}


[LoggingExample.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/LoggingExample.vb){#gitlink-id target=_blank}

Logging Identifier​

The LogIdentifier enumeration categorizes the log entry source. It is the third entry written to the log. For example, if logging was enabled and converting an HTML document followed by a Word document, the following would appear in the logging output, where Html identified the logging source was HTML conversion and Word identified the logging source was Word.

[023160][Information ][Html ] Current session closed...
[023160][Information ][Word ] WordConverter constructor2 called

Log entries have the following possible identifiers.

Logging IdentifierDescription
LogIdentifier.Conversion2Log entry originated from conversion code not specific to any type.
LogIdentifier.Excel5Log entry originated from ExcelConverter code.
LogIdentifier.Html7Log entry originated from HtmlConverter code.
LogIdentifier.Image8Log entry originated from ImageConverter code.
LogIdentifier.Other3Log entry originated from other miscellaneous code.
LogIdentifier.PowerPoint6Log entry originated from PowerPointConverter code.
LogIdentifier.Rtf10Log entry originated from RtfConverter code.
LogIdentifier.Service1Log entry originated from service code.
LogIdentifier.Text9Log entry originated from TextConverter code.
LogIdentifier.Visio11Log entry originated from VisioConverter code.
LogIdentifier.Word4Log entry originated from WordConverter code.

Logger Delegate​

Converter's logging also has a LoggerDelegate class that allows defining a delegate to handle logging.

ConversionOptions.Logging.Level = LogLevel.Debug;
ConversionOptions.Logging.LogAction = DelegateMethod;

public static void DelegateMethod(LogIdentifier identifier, LogLevel logLevel, string message)
{
Console.WriteLine(logLevel + "|" + identifier + "|" + message);
}
ConversionOptions.Logging.Level = LogLevel.Debug
ConversionOptions.Logging.LogAction = AddressOf DelegateMethod

Public Shared Sub DelegateMethod(identifier As LogIdentifier, logLevel As LogLevel, message As String)
Console.WriteLine(logLevel.ToString() & "|" & identifier.ToString() & "|" & message)
End Sub

[LoggingExample.cs](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-cs/LoggingExample.cs){#gitlink-id target=_blank}


[LoggingExample.vb](https://github.com/DynamicPDF/converter-dotnet-core/blob/master/converter-dotnet-core-console-vb/LoggingExample.vb){#gitlink-id target=_blank}