Skip to content

Commit b8e2d60

Browse files
committed
Document logging. Fixes #417
1 parent 0ac0dd1 commit b8e2d60

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

docs/UsingLog4netLogging.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## How to Use
2+
3+
To integrate MySqlConnector with log4net, add the following line of code to your application startup routine (before any `MySqlConnector` objects have been used):
4+
5+
```
6+
MySqlConnectorLogManager.Provider = new Log4netLoggerProvider();
7+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## How to Use
2+
3+
To integrate MySqlConnector with Microsoft.Extensions.Logging, add the following line of code to your `Startup.Configure` method (before any `MySqlConnector` objects have been used):
4+
5+
```
6+
MySqlConnectorLogManager.Provider = new MicrosoftExtensionsLoggingLoggerProvider(loggerFactory);
7+
```

docs/content/overview/logging.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
date: 2018-01-20
3+
menu:
4+
main:
5+
parent: getting started
6+
title: Logging
7+
weight: 50
8+
---
9+
10+
Logging
11+
=======
12+
13+
MySqlConnector implements a custom logging framework with the `IMySqlConnectorLogger` and `IMySqlConnectorLoggerProvider` interfaces.
14+
To connect MySqlConnector to an existing logging framework, write an implementation of `IMySqlConnectorLoggerProvider` that adapts
15+
the existing logging framework, and install it by setting `MySqlConnector.Logging.MySqlConnectorLogManager.Provider = provider;`.
16+
17+
The `MySqlConnectorLogManager.Provider` property may only be set once, and must be set before any other MySqlConnector library methods are called.
18+
19+
### Existing Logging Providers
20+
21+
There are NuGet packages that adapt MySqlConnetor logging for popular logging frameworks.
22+
23+
#### log4net
24+
25+
Install [MySqlConnector.Logging.log4net](https://www.nuget.org/packages/MySqlConnector.Logging.log4net/).
26+
27+
Add the following line of code to your application startup routine:
28+
29+
MySqlConnectorLogManager.Provider = new Log4netLoggerProvider();
30+
31+
#### Microsoft.Extensions.Logging
32+
33+
Install [MySqlConnector.Logging.Microsoft.Extensions.Logging](https://www.nuget.org/packages/MySqlConnector.Logging.Microsoft.Extensions.Logging/).
34+
35+
Add the following line of code to your `Startup.Configure` method:
36+
37+
MySqlConnectorLogManager.Provider = new MicrosoftExtensionsLoggingLoggerProvider(loggerFactory);

docs/content/overview/use-with-orms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ menu:
55
main:
66
parent: getting started
77
title: Use with ORMs
8-
weight: 50
8+
weight: 60
99
---
1010

1111
Use with ORMs

0 commit comments

Comments
 (0)