.net core框架下nlog不记录:
1.安装NLog.Web.AspNetCore
2.在Startup.cs文件的方法public void Configure(IApplicationBuilder app, IHostingEnvironment env)中,添加下面一行代码:
env.ConfigureNLog(“NLog.config”);
Nlog默认配置:
<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <variable name="logDirectory" value="${basedir}/Logs" /> <targets async="true"> <target name="file" xsi:type="File" layout="${longdate} ${threadid:padding=4} ${level:uppercase=true:padding=5} ${logger:shortName=true} ${message} ${exception:format=tostring}" fileName="${logDirectory}/log.txt" archiveFileName="${logDirectory}/log.{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" concurrentWrites="true" createDirs="true" autoFlush="true" /> </targets> <rules> <logger name="*" minlevel="Trace" writeTo="file" /> </rules> </nlog>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/2385.html