I want to use Serilog for logging because I worked with it and it fits my needs.
The difference in this case is that I need to log different modules and I would like each module to be logged in a different folder and even maybe in a different sink.
I am not talking about using several sinks, but I talk about doing something like this:
Serilog.Log(LogInstance1,"Log for module 1") // Logs in a rolling text file in folder X 10 files of 1MB each
Serilog.Log(LogInstance2,"Log for module 2") // Logs i na text file that doesn't delete old entries
Does anyone know if this is possible to achieve with Serilog?
You can make multiple separate ILogger
instances, each with their own configuration and set of sinks etc.; each pipeline operates completely separately with no shared state of any kind.
var logger1 = new LoggerConfiguration().
.WriteTo.File(...10...)
.CreateLogger();
var logger2 = new LoggerConfiguration()
.WriteTo.File(...)
.CreateLogger();
logger1.Information("Log for Module 1");
logger2.Information("Log for Module 2");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With