I'd like to add a Serilog Log
to a static class in my program like this (DataHelper
is the class name):
private readonly ILogger _log = Log.ForContext<DataHelper>();
But this leads to the error message:
static types cannot be used as type arguments
Which makes sense. So how do I inject the logger (which is working fine in non-static classes) to this class?
Update: The answer to you referred question suggests that it is not possible. But according to Serilog's Github, there is a workaround. I just need log to be aware of the class it is logging from. For now, it seems as if it is logging from the main class.