Closed slimshader closed 1 month ago
Try the following:
var loggerFactory = LoggerFactory.Create(x => x.AddZLoggerUnityDebug());
builder.RegisterInstance(loggerFactory);
builder.Register(typeof(Logger<>), Lifetime.Singleton).As(typeof(ILogger<>));
Note:
new Logger<T>(ILoggerFactory)
is called by VContainer.Thanks, this indeed solves this case, but what in general?
Let's say I have (not purely hypothetical):
and I want objects to be able to inject specific instance of ILogger direclty like so:
docs have "Register Open Generics" section but I see no Register overload that would allow to pass CreateLogger as a factory method to Register(typeof(Ilogger<>)