更新时间:2023-02-15 23:20:56
我最终要做的是使用NLog,而不是使用他们的.NET Core DI扩展,我只添加了教程到 GetCurrentClassLogger()
,将其创建为我班上的一个静态成员,然后直接将其用于日志记录.这是一个非常简单的设置,不需要DI.NLog可能会更好地记录它.
What I ended up doing was using NLog but rather than using their .NET Core DI extensions, I just included the main NLog NuGet package, manually creating my own NLog.config
file, and followed the tutorial to GetCurrentClassLogger()
, creating that as a static member of my class, then directly used that for logging. This is quite a simple setup and has no need for DI. NLog should probably document it better.