ramondeklein/nwebdav

Use DI instead of static

cfauchere opened this issue · 3 comments

For logging it would be best to use DI instead of static objects and custom implementation of ILogger. MSFT already provides ILogger, extension methods, ILoggerFactory. Using your own definition of ILogger and ILogger factory does not integrate easily with the framework. At least use the MSFT interfaces but best would be to leverage DI as well so own does not have to handle the injection in the different classes (which is probably why you have the static)

You're absolutely right. When I developed NWebDAV we used Log4NET and it uses statics everywhere, which is why this deisgn was used. It should be changed to the .NET Core standard of ILogger instead. It's certainly on the list to do, but I also want to maintain backwards compatibility for existing users.

What was the intend behind the objects in NWebDav.Server.Logging? Do you expect clients to provide an implementation of NWebDav.Server.Logging.ILogger as an adapter to their logging framework?