Open SAILAKSHMIBHATTARAM opened 3 years ago
You can place three backticks (`) before and after your code to create a code block.
just
like
this
Thanks for getting in touch @SAILAKSHMIBHATTARAM - Stack Overflow is a better option for usage questions, as there are more people over there able to answer.
Hi I'm using serilog and trying writeto.File(), reading configuration from appsettings.json file.. But the problem here is I need two log files based on the application name, since I will be using the serilog project as a utility based on the Assembly from which the application is running I should create respective files. I tried adding filters in json file for writeto tag there is no luck. { "Serilog": { "Using": [ "Serilog.Sinks.File" ], "FilterSwitches": { "$filterSwitch": "Application = 'Adaptor.Service'"}, "MinimumLevel": { "Default": "Debug" }, "WriteTo": [ { "Name": "Logger", "Args": { "configureLogger": { "Filter": [ { "Name": "ByIncludingOnly", "Args": { "inclusionPredicate": { "logEvent": { "Properties": { "Application": "Adaptor.Service" } } } } } ], "Enrich": [ "FromLogContext", "WithMachineName", { "Name": "When", "Args": { "expression": "Application = Adaptor.Service'" }, "configureEnricher": [ "WithMachineName", "FromLogContext", "WithThreadId" ] } ], "WriteTo": [ { "Name": "File", "Args": { "path": "%TEMP%/Logs/AdaptorConfig2.txt", "outputTemplate": "[{Timestamp:HH:mm:ss}] {SourceContext} [{Level}] {Message}{NewLine}{Exception}" } } ] } } }, { "Name": "Logger", "Args": { "configureLogger": { "Filter": [ { "Name": "ByIncludingOnly", "Args": { "inclusionPredicate": { "logEvent": { "Properties": { "Application": "TestApp.Service" } } } } } ], "Enrich": [ "FromLogContext", "WithMachineName", { "Name": "When", "Args": { "expression": "Application = 'TestApp.Service'" }, "configureEnricher": [ "WithMachineName", "FromLogContext", "WithThreadId" ] } ], "WriteTo": [ { "Name": "File", "Args": { "path": "%TEMP%/Logs/TestAppConfig2.txt", "outputTemplate": "[{Timestamp:HH:mm:ss}] {SourceContext} [{Level}] {Message}{NewLine}{Exception}" } } ] } } } ] } }