You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/diagnostics/logging.md
+51-3Lines changed: 51 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,64 @@ title: Logging
8
8
weight: 10
9
9
---
10
10
11
-
Logging
12
-
=======
11
+
# Logging
12
+
13
+
MySqlConnector 2.3.0 and later supports logging through the standard [Microsoft.Extensions.Logging](https://learn.microsoft.com/en-us/dotnet/core/extensions/logging) interfaces.
14
+
15
+
## Console Programs
16
+
17
+
To set up logging in MySqlConnector, create your `ILoggerFactory` as usual, and then configure a `MySqlDataSource` with it.
18
+
Any use of connections handed out by the data source will log via your provided logger factory.
19
+
20
+
The following shows a minimal console application logging to the console via [Microsoft.Extensions.Logging.Console](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console):
21
+
22
+
```csharp
23
+
usingMicrosoft.Extensions.Logging;
24
+
usingMySqlConnector;
25
+
26
+
// Create a Microsoft.Extensions.Logging LoggerFactory, configuring it with the providers,
If you're using ASP.NET, you can use the additional [MySqlConnector.DependencyInjection package](https://www.nuget.org/packages/MySqlConnector.DependencyInjection), which provides seamless integration with dependency injection and logging:
0 commit comments