Skip to content

Commit eceec78

Browse files
authored
Merge pull request #28 from joostas/docs-appsettings-example
Docs: add configuration from appsettings.json example
2 parents 42951b6 + 1e9815a commit eceec78

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,34 @@ Log.Logger = new LoggerConfiguration()
2525
.WriteTo.File(new CompactJsonFormatter(), "./logs/myapp.json")
2626
.CreateLogger();
2727
```
28-
28+
#### XML `<appSettings>` configuration
2929
To specify the formatter in XML `<appSettings>` provide its assembly-qualified type name:
3030

3131
```xml
3232
<appSettings>
33-
<add key="serilog:using:File" value="Serilog.Sinks.RollingFile" />
33+
<add key="serilog:using:File" value="Serilog.Sinks.File" />
3434
<add key="serilog:write-to:File.path" value="./logs/myapp.json" />
3535
<add key="serilog:write-to:File.formatter"
3636
value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
3737
```
38+
#### JSON `appsettings.json` configuration
39+
To specify formatter in json `appsettings.json` provide its assembly-qualified type name:
40+
41+
```json
42+
{
43+
"Serilog": {
44+
"WriteTo": [
45+
{
46+
"Name": "File",
47+
"Args": {
48+
"path": "./logs/myapp.json",
49+
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact"
50+
}
51+
}
52+
]
53+
}
54+
}
55+
```
3856

3957
### Rendered events
4058

0 commit comments

Comments
 (0)