I\'m logging just fine using dependency injection on my controllers, now I need to log something from a static class.
How can I log from
First of all, I agree with NightOwl888 answer.
But as an option (consider this as a workaround) you could inject ILogger
dependency via method parameter => so a class that will call this static method should be responsible for providing a correct implementation of ILogger
.
static class YourClass
{
public static void DoSomething(ILogger logger)
{
// do something
// call log.Log();
}
}