I have a redisprovider class in my Azure Function:
public RedisCacheProvider(ILogger<RedisCacheProvider> logger,
IConnectionMultiplexer connectionMultiplexer)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
multiplexer = connectionMultiplexer;
}
I am adding this class as a singleton but how do I initialise the Ilogger in the startup class. I am aware it is injected by Azure Functions into the classes. If so, how do I manage this in the startup class when we need to initialise other objects for the class on startup?
services.AddSingleton<ICacheProvider>(serviceProvider =>
new RedisCacheProvider(**???**, serviceProvider.GetRequiredService<IConnectionMultiplexer>()));
Usually, I do this:
services.AddSingleton<IHttpService, HttpService>();
In the RedisProvider class, I need to pass my connection string. So how do I inject the ILogger when I pass the IConnectionMultiplexer?