struggeling with iLogger. For me it is currently not clear how to instantiate a logging instance aside the web controller.
In main I'm staging a "version monitor":
public static void Main(string[] args)
{
IWebHostEnvironment env;
VersionMonitor vControl = new VersionMonitor();
CreateHostBuilder(args).Build().Run();
}
Within the version monitor constructor I'm starting a timer:
public VersionMonitor()
{
Timer timer = new Timer();
timer.Interval = UpInterval;
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
}
All I want to do, is now to log sth. within the elapsed timer event:
static void timer_Elapsed(object sender, ElapsedEventArgs e)
{
//how to?
ILogger<timer_Elapsed> _logger;
logger.LogInformation("Message");
}
Could you guide me, how to do this, please?
Thanks in advance.