I have a class library project which i am referring from my main console application (The class i am using is ProcessService
).
If the constructor would take only ILogger as an argument like this:
public ProcessService(ILogger factory)
{
}
And then i register it in ConfigureServices(IServiceCollection services)
Like this:
services.AddSingleton<IProcessService, ProcessService>();
It works fine. The problem is that i need to pass other then ILogger another argument which i take from appsettings so the constructor of the class looks like this:
public ProcessService(int period,ILogger factory){}
And then im trying to register it like this:
services.AddSingleton<IProcessService>(new ProcessService(refreshInterval*1000,ILogger logger));
But i have to pass an initialized logger and its not correct. What is the way to achieve my requirement?