You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
`
But also being able to inject those two loggers in my constructors to be able to log inside MyServiceAppender or DataAppender using the DEBUG level.
`myServiceLogger.LogDebug("test");` goes to Infos.log
`myDataLogger.LogDebug("test");` goes to Data.log
Is there any way to achieve this ?
Thanks for the help.
The text was updated successfully, but these errors were encountered:
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);
`
`
What I'd like is :
Configure in log4net two loggers, one for the on-the-fly infos, one for the on-the-fly datas.
Is there any way to achieve this ?
Thanks for the help.
The text was updated successfully, but these errors were encountered: