Skip to content

Commit 16d1ca9

Browse files
committed
Describe how to write JSON output
1 parent e68cf8d commit 16d1ca9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ That's it! With the level bumped up a little you will see log output resembling:
7878
[22:14:45.741 DBG] Handled. Status code: 304 File: /css/site.css
7979
```
8080

81-
Tip: to see Serilog output in the Visual Studio output window when running under IIS, either select _ASP.NET Core Web Server_ from the _Show output from_ drop-down list, or replace `WriteTo.Console()` in the logger configuration with `WriteTo.Debug()`.
81+
**Tip:** to see Serilog output in the Visual Studio output window when running under IIS, either select _ASP.NET Core Web Server_ from the _Show output from_ drop-down list, or replace `WriteTo.Console()` in the logger configuration with `WriteTo.Debug()`.
8282

83-
A more complete example, showing _appsettings.json_ configuration, can be found in [the sample project here](https://github.com/serilog/serilog-aspnetcore/tree/dev/samples/EarlyInitializationSample).
83+
A more complete example, showing `appsettings.json` configuration, can be found in [the sample project here](https://github.com/serilog/serilog-aspnetcore/tree/dev/samples/EarlyInitializationSample).
8484

8585
### Request logging <sup>`3.0.0-*`</sup>
8686

@@ -215,6 +215,16 @@ If [inline initialization](#inline-initialization) is used, providers can be ena
215215
writeToProviders: true)
216216
```
217217

218+
### JSON output
219+
220+
The `Console()`, `Debug()`, and `File()` sinks all support JSON-formatted output natively, via the included _Serilog.Formatting.Compact_ package.
221+
222+
To write newline-delimited JSON, pass a `CompactJsonFormatter` or `RenderedCompactJsonFormatter` to the sink configuration method:
223+
224+
```csharp
225+
.WriteTo.Console(new RenderedCompactJsonFormatter())
226+
```
227+
218228
### Writing to the Azure Diagnostics Log Stream
219229

220230
The Azure Diagnostic Log Stream ships events from any files in the `D:\home\LogFiles\` folder. To enable this for your app, add a file sink to your `LoggerConfiguration`, taking care to set the `shared` and `flushToDiskInterval` parameters:

0 commit comments

Comments
 (0)