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
I hope I understood the meaning of this extension correctly. I would expect to get a different logger for every class that is resolved and needs an ILogger. Currently only the first resolve leads to a new ILogger-object which is passed to all other classes that also need an ILogger.
From my understanding the following test should result in two different loggerinstances but the test fails as they are the same (just paste it into the existing test class, I was unsure if I should have made this a pull-request since I could not provide a solution):
[TestMethod]
public void NLog_different()
{
LoggedType2 instance2 = _container.Resolve<LoggedType2>();
Assert.AreNotSame(instance2.Logger,
_instance.Logger);
}
public class LoggedType2
{
public LoggedType2(ILogger log)
{
Logger = log;
}
public ILogger Logger { get; }
}
I hope I made this issue clear enough as I am fairly new to Unity.
Activity
ChrisAndrews333 commentedon Aug 29, 2019
Any fix for this?
KifKot commentedon Feb 18, 2020
This approach has worked for me:
janschreier commentedon Feb 18, 2020
I can confirm that this works like a charm and created a PR that is a bit less changing than what you suggested KifKot. Thanks for solving that issue!
Update NLogExtension.cs