Open tiofred opened 2 years ago
I found a way to achieve this, with dependency injection.
I write it here, it might be useful for someone else :
I replaced in the constructor's prototype
ILogger<AcquisitionManager> myLogger
by
ILoggerFactory loggerFactory
and added
ILogger myServiceLogger = loggerFactory.CreateLogger("MyService"); ILogger myDataLogger = loggerFactory.CreateLogger("DataService");
I leave it open for now, if you think that's the right way it should be closed. If there's another way, I'd be glad to hear about it.
Hello. I achieved this : Using dependency injection, I managed to load log4net confile and to pass ILogger<> to constructors. It works fine with a root logger and multiple appenders filtering the level, so i.e. it logs DEBUG to a file and ERROR to another.
.ConfigureLogging(logging => { logging.ClearProviders(); logging.SetMinimumLevel(LogLevel.Trace); logging.AddLog4Net("config.log4Net.xml", true);
`<?xml version="1.0" encoding="utf-8" ?>