use a none generic ILogger in your base class, but ILogger<DerivedClass>
in your derived class. This way you can simply pass the ILogger to your base class if needed:
public abstract class BaseClassExample
{
private readonly ILogger logger;
public class BaseClassExample(ILogger logger)
{
this.logger = logger;
}
}
and
public class DerivedClass : BaseClassExample
{
private readonly ILogger<DerivedClass> logger;
public class BaseClassExample(ILogger<DerivedClass> logger)
:base(logger)
{
this.logger = logger;
}
}
this way not only you can use it easier if you somehow end up with two derived class you can use ILogger in both of them.