Skip to content

Commit 6df25c9

Browse files
authored
Merge pull request #16 from tsimbalar/doc-minimul-level-overrides
Add doc for serilog:minimum-level:override: [Skip CI]
2 parents 9653d81 + a5548fa commit 6df25c9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,25 @@ For example, to add the property `Release` with the value `"1.2-develop"` to all
104104
<add key="serilog:enrich:with-property:Release" value="1.2-develop" />
105105
```
106106

107+
### Adding minimum level overrides
108+
109+
Since Serilog 2.1, [minimum level overrides](https://nblumhardt.com/2016/07/serilog-2-minimumlevel-override/) can be added to change the minimum level for some specific namespaces. This is done with the setting key `serilog:minimum-level:override:` followed by the *source context prefix*.
110+
111+
For instance, the following are equivalent :
112+
113+
```csharp
114+
Log.Logger = new LoggerConfiguration()
115+
.MinimumLevel.Information()
116+
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
117+
.MinimumLevel.Override("Microsoft.AspNetCore.Mvc", LogEventLevel.Error)
118+
```
119+
120+
and in XML
121+
122+
```xml
123+
<add key="serilog:minimum-level" value="Information" />
124+
<add key="serilog:minimum-level:override:Microsoft" value="Warning" />
125+
<add key="serilog:minimum-level:override:Microsoft.AspNetCore.Mvc" value="Error" />
126+
```
127+
107128
See the [Serilog documentation](https://github.com/serilog/serilog/wiki/AppSettings) for further information.

0 commit comments

Comments
 (0)