Skip to content

Commit 8f241f8

Browse files
authored
Merge pull request serilog#326 from nblumhardt/json-examples
Mark partial and invalid JSON code snippets as YAML
2 parents 736aa1a + 248749d commit 8f241f8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ For a more sophisticated example go to the [sample](sample/Sample) folder.
5656

5757
Root section name can be changed:
5858

59-
```json
59+
```yaml
6060
{
6161
"CustomSection": {
6262
...
@@ -74,7 +74,7 @@ var logger = new LoggerConfiguration()
7474

7575
`Using` section contains list of **assemblies** in which configuration methods (`WriteTo.File()`, `Enrich.WithThreadId()`) reside.
7676

77-
```json
77+
```yaml
7878
"Serilog": {
7979
"Using": [ "Serilog.Sinks.Console", "Serilog.Enrichers.Thread", /* ... */ ],
8080
// ...
@@ -83,7 +83,7 @@ var logger = new LoggerConfiguration()
8383

8484
For .NET Core projects build tools produce `.deps.json` files and this package implements a convention using `Microsoft.Extensions.DependencyModel` to find any package among dependencies with `Serilog` anywhere in the name and pulls configuration methods from it, so the `Using` section in example above can be omitted:
8585

86-
```json
86+
```yaml
8787
{
8888
"Serilog": {
8989
"MinimumLevel": "Debug",
@@ -195,7 +195,7 @@ Or alternatively, the long-form (`"Name":` ...) syntax from the example above ca
195195

196196
By `Microsoft.Extensions.Configuration.Json` convention, array syntax implicitly defines index for each element in order to make unique paths for configuration keys. So the example above is equivalent to:
197197

198-
```json
198+
```yaml
199199
"WriteTo": {
200200
"0": "Console",
201201
"1": "DiagnosticTrace"
@@ -204,7 +204,7 @@ By `Microsoft.Extensions.Configuration.Json` convention, array syntax implicitly
204204

205205
And
206206

207-
```json
207+
```yaml
208208
"WriteTo:0": "Console",
209209
"WriteTo:1": "DiagnosticTrace"
210210
```
@@ -213,7 +213,7 @@ And
213213

214214
When overriding settings with [environment variables](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1#environment-variables) it becomes less convenient and fragile, so you can specify custom names:
215215

216-
```json
216+
```yaml
217217
"WriteTo": {
218218
"ConsoleSink": "Console",
219219
"DiagnosticTraceSink": { "Name": "DiagnosticTrace" }
@@ -228,7 +228,7 @@ This section defines a static list of key-value pairs that will enrich log event
228228

229229
This section defines filters that will be applied to log events. It is especially usefull in combination with _[Serilog.Expressions](https://github.com/serilog/serilog-expressions)_ (or legacy _[Serilog.Filters.Expressions](https://github.com/serilog/serilog-filters-expressions)_) package so you can write expression in text form:
230230

231-
```json
231+
```yaml
232232
"Filter": [{
233233
"Name": "ByIncludingOnly",
234234
"Args": {
@@ -239,7 +239,7 @@ This section defines filters that will be applied to log events. It is especiall
239239

240240
Using this package you can also declare `LoggingFilterSwitch`-es in custom section and reference them for filter parameters:
241241

242-
```json
242+
```yaml
243243
{
244244
"Serilog": {
245245
"FilterSwitches": { "filterSwitch": "Application = 'Sample'" },
@@ -260,7 +260,7 @@ Level updates to switches are also respected for a dynamic update.
260260

261261
Some Serilog packages require a reference to a logger configuration object. The sample program in this project illustrates this with the following entry configuring the _[Serilog.Sinks.Async](https://github.com/serilog/serilog-sinks-async)_ package to wrap the _[Serilog.Sinks.File](https://github.com/serilog/serilog-sinks-file)_ package. The `configure` parameter references the File sink configuration:
262262

263-
```json
263+
```yaml
264264
"WriteTo:Async": {
265265
"Name": "Async",
266266
"Args": {
@@ -286,7 +286,7 @@ When the configuration specifies a discrete value for a parameter (such as a str
286286

287287
Static member access can be used for passing to the configuration argument via [special](https://github.com/serilog/serilog-settings-configuration/blob/dev/test/Serilog.Settings.Configuration.Tests/StringArgumentValueTests.cs#L35) syntax:
288288

289-
```json
289+
```yaml
290290
{
291291
"Args": {
292292
"encoding": "System.Text.Encoding::UTF8",
@@ -299,7 +299,7 @@ Static member access can be used for passing to the configuration argument via [
299299

300300
If the parameter value is not a discrete value, it will try to find a best matching public constructor for the argument:
301301

302-
```json
302+
```yaml
303303
{
304304
"Name": "Console",
305305
"Args": {
@@ -317,7 +317,7 @@ For other cases the package will use the configuration binding system provided b
317317

318318
If parameter type is an interface or an abstract class you need to specify the full type name that implements abstract type. The implementation type should have parameterless constructor.
319319

320-
```json
320+
```yaml
321321
"Destructure": [
322322
{ "Name": "With", "Args": { "policy": "Sample.CustomPolicy, Sample" } },
323323
...

0 commit comments

Comments
 (0)