Skip to content

Commit

Permalink
Merge pull request #364 from RandomBuffer/FixPushPropertyExample
Browse files Browse the repository at this point in the history
Fix properties example to use LogContext
  • Loading branch information
nblumhardt committed Mar 5, 2024
2 parents 11ae421 + 178f6df commit 0b2a9ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ using (logger.BeginScope(new Dictionary<string, object>
}
```

The code above results in the same outcome as if you would push properties in the **ILogger** in Serilog.
The code above results in the same outcome as if you would push properties in the **LogContext** in Serilog. More details can be found in https://github.com/serilog/serilog/wiki/Enrichment#the-logcontext.

```csharp
// Serilog ILogger
using (logger.PushProperty("UserId", "svrooij"))
using (logger.PushProperty("OperationType", "update"))
// Serilog LogContext
using (LogContext.PushProperty("UserId", "svrooij"))
using (LogContext.PushProperty("OperationType", "update"))
{
// UserId and OperationType are set for all logging events in these brackets
}
Expand Down

0 comments on commit 0b2a9ab

Please sign in to comment.