SanitizedLogger and ILogger registration #439
|
I am working on migrating DuendeSoftware.IdentityServer from 7.2.* to 7.4.* and I am facing an issue related to ILogger registration in DI. serviceCollection.AddSingleton<ILogger>(sp =>
{
...
});
serviceCollection.AddSingleton<ILoggerFactory>(sp =>
{
...
});Starting with v7.3, PR DuendeSoftware/products#1806 public SanitizedLogger(ILogger<T> logger)
{
_logger = logger;
}
public SanitizedLogger(ILogger logger)
{
_logger = logger;
}Because of that, DI resolution started to fail with the following error: Do you have any advice on how to resolve this? Removing serviceCollection.AddSingleton is not an option for us: it is part of our shared platform code and would require a large number of changes. I also tried to adjust registrations in DI for classes that use SanitizedLogger, but it would require reflection and does not look like production-quality code. To reproduce the issue, add the following to IdentityServer startup code: builder.Services.AddSingleton<ILogger>(_ => NullLogger.Instance);
builder.Services.AddSingleton<ILoggerFactory>(_ => new NullLoggerFactory()); |
Replies: 2 comments 2 replies
|
Thanks for reporting! Reason seems to indeed be with Working with the dev team to see what is possible here. I'm afraid there is no current workaround other than remaining on pre-7.3 or removing the registrations you have there. |
|
@kRaBby we've just released IdentityServer 7.4.4 (and IdentityServer 7.3.4), which should fix this issue. Please give them a try and let us know how you get on! |
@kRaBby we've just released IdentityServer 7.4.4 (and IdentityServer 7.3.4), which should fix this issue.
Please give them a try and let us know how you get on!