.net core 3.1+efcore+NLog,如何把SQL记录到Log文件?
艰难探索中 2020-10-23 08:44:49 环境:.net core 3.1 webapi+efcore+NLog
代码:
1、引用NLog、NLog.Web.AspNetCore、NLog.Extensions.Logging
参考代码:
https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-3
2、Startup.cs里参考代码:
https://www.cnblogs.com/puzi0315/p/13488173.html
运行结果:
启动时在“CreateHostBuilder”函数报错:Unable to resolve service for type ILoggerFactory
怀疑是NLog没有绑定到ILoggerFactory上,但没找到解决方法
Q:为什么用NLog?
A:原来项目升级过来的