且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET Core 2.1使用Nlog配置作为.NET MVC5

更新时间:2023-02-16 13:13:36

与其在Controller中设置日志,不如考虑遵循以下Wiki:

Instead of setting up logging in the Controller then consider following the wiki: https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2

确保已安装nuget-package System.Data.SqlClient以便在NetCore上使用DatabaseTarget.

Make sure that you have installed nuget-package System.Data.SqlClient to use DatabaseTarget on NetCore.

确保已检查NLog InternalLogger: https://github.com /NLog/NLog/wiki/内部记录

Make sure that you have checked the NLog InternalLogger: https://github.com/NLog/NLog/wiki/Internal-Logging

NLog.Web.AspNetCore版本. 4.8.0允许您使用${configsetting}从appsettings.json中分配ConnectionString: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer .

NLog.Web.AspNetCore ver. 4.8.0 allows you to use the ${configsetting} to assign ConnectionString from appsettings.json: https://github.com/NLog/NLog/wiki/ConfigSetting-Layout-Renderer.