serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
446 stars 129 forks source link

How to configure with multiple instances of same app/executable? #335

Open askids opened 1 year ago

askids commented 1 year ago

hi,

I have an app that runs multiple instances of .Net windows Service (like Instance1, Instance2 etc) using same exe, but with different arguments. Now I am trying to add Serilog configuration to this app and planning to use File sink. In such case, how can I make sure that each instance is using its own file as the appsettings file will be common?

Thanks!

sungam3r commented 1 year ago

You can pass different names via environment variables https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0#non-prefixed-environment-variables or command line https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0#command-line to override "fixed" setting from json configuration file.