This may be somewhat related to Pass ILogger or ILoggerFactory to constructors in AspNet Core?, however this is specifically about Library Design, not about
For library design good approach would be:
1.Do not force consumers to inject logger to your classes. Simply create another ctor passing NullLoggerFactory.
class MyClass
{
private readonly ILoggerFactory _loggerFactory;
public MyClass():this(NullLoggerFactory.Instance)
{
}
public MyClass(ILoggerFactory loggerFactory)
{
this._loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
}
}
2. Limit number of categories which you use when you create loggers to allow consumers configure logs filtering easily.
this._loggerFactory.CreateLogger(Consts.CategoryName)