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
To start using the DynamicSwitch, the sink can be setup as follows:
24
+
## Using
25
+
26
+
### Setup sinks
27
+
28
+
A DynamicSwitch sink can be set up in the standard way while constructing a `LoggerConfiguration`. A specific `LoggingLevelSwitchCollection` object can be passed to the configuration; if one is not specified, a static global collection is used that be referenced using `LoggingLevelSwitchCollection.Current`. Each DynamicSwitch must be uniquely named. The following is a simple example:
@@ -32,7 +36,7 @@ var log = new LoggerConfiguration()
32
36
.CreateLogger();
33
37
```
34
38
35
-
If using `appsettings.json` for configuration, the following example shows how to configure DynamicSwitch sinks:
39
+
If using `appsettings.json` for configuration, the following example shows how to configure DynamicSwitch sinks along with attached level switches:
36
40
37
41
```javascript
38
42
{
@@ -82,7 +86,9 @@ If using `appsettings.json` for configuration, the following example shows how t
82
86
}
83
87
```
84
88
85
-
Next, add the level switch collection to your services collection:
89
+
#### Using Dependency Injection
90
+
91
+
To support the retrieval of switches through dependency injection, there is a simple extention method to add the collection to the services container. If a collection is not passed, the global `LoggingLevelSwitchCollection.Current` will be added to the container:
0 commit comments