From 7b72dc866fb7954ca239d4c584c60136d850f6db Mon Sep 17 00:00:00 2001 From: Stefan Ossendorf Date: Fri, 31 May 2019 16:51:22 +0200 Subject: [PATCH] Example completed Readme added & example fixed to reflect out of the box usage. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 32eeed5..d4e0d26 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,19 @@ Log.Logger = new LoggerConfiguration() ``` Many sinks simply include all properties without further action required, so the thread id will be logged automatically. -However, some sinks, such as the File and Console sinks use an output template and the new ThreadId may not be automatically output in your sink. In this case, in order for the ThreadId to show up in the logging, you will need to create or modify your output template. +However, some sinks, such as the File and Console sinks use an output template and the new ThreadId may not be automatically output in your sink. In this case, in order for the ThreadId or ThreadName to show up in the logging, you will need to create or modify your output template. ```csharp w.File(...., outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj} {Properties}{NewLine}{Exception}") ``` -Here, {Properties} can include not only ThreadId, but any other enrichment which is applied. Alternatively, {ThreadId} could be used instead, if you want to only add the thread id enrichment or {ThreadName}, if you want to only add the thread name enrichment. +Here, {Properties} can include not only ThreadId and ThreadName, but any other enrichment which is applied. Alternatively, {ThreadId} could be used instead, if you want to only add the thread id enrichment and {ThreadName}, if you want to only add the thread name enrichment. An example, which also uses the Serilogs.Sinks.Async Nuget package, is below: ```csharp + Thread.CurrentThread.Name = "MyWorker"; + var logger = Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console(restrictedToMinimumLevel:Serilog.Events.LogEventLevel.Information)