EDB .NET Connector logging v8.0.5.1
EDB .NET Connector supports the use of logging to help resolve issues with the .NET Connector when used in your application. EDB .NET Connector supports logging using the standard .NET Microsoft.Extensions.Logging
package. For more information about logging in .Net, see Logging in C# and .NET in the Microsoft documentation.
Note
For versions earlier than 7.x, EDB .NET Connector had its own, custom logging API.
Console logging provider
The .NET logging API works with a variety of built-in and third-party logging providers. The console logging provider logs output to the console.
Console logging with EDBDataSource
Create a Microsoft.Extensions.Logging.LoggerFactory
and configure an EDBDataSource
with it. Any use of connections opened through this data source log using this logger factory.
Console logging without EDBDataSource
Create a Microsoft.Extensions.Logging.LoggerFactory
and configure EDB .NET Connector's logger factory globally using EDBLoggingConfiguration.InitializeLogging
. Configure it at the start of your program, before using any other EDB .NET Connector API.
Log levels
The following log levels are available:
- Trace
- Debug
- Information
- Warning
- Error
- Fatal
This example shows how to change the log level to Trace
:
Formatting the log output
This example shows how to format your log output. Create a LoggerFactory
to restrict each log message to a single line and add a date and time to the log: