Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Serilog Enrichers using App Config

Tags:

json

c#

serilog

For Serilog logs enrichment using an App config how can i add standard enrichers like ProcessId, ThreadId, MachineName? The syntax to add property enricher is below but am trying to use the above standard enrichers. There's an option to implement application json which i want to avoid as it needs Serilog 2.6. Any ideas how this can be done?

<add key="serilog:enrich:with-property:Version" value="1.0" />
like image 775
Noah Avatar asked Sep 02 '25 16:09

Noah


1 Answers

Add the standard enricher with the below syntax, you also need to refer the dll for the enricher, see below for ThreadId enricher.

    <add key="serilog:using:Thread" value="Serilog.Enrichers.Thread" />
    <add key="serilog:enrich:WithThreadId" /> 
like image 54
Noah Avatar answered Sep 05 '25 07:09

Noah