1.1选择项目

ASP.NET Core之NLog使用

1.2选择.Net版本

ASP.NET Core之NLog使用

 

2. 添加NLog插件

2.1 通过Nuget安装

ASP.NET Core之NLog使用

2.2下载相关的插件

ASP.NET Core之NLog使用

 

 

3.修改NLog配置文件

3.1添加NLog配置文件

ASP.NET Core之NLog使用

 

3.2修改NLog.config配置文件

配置文件全部内容:

 1 <?xml version="1.0" encoding="utf-8" ?>
 2 <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
 3       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4       autoReload="true"
 5       internalLogLevel="Warn"
 6       internalLogFile="internal-nlog.txt">
 7 
 8   <!--define various log targets-->
 9   <targets>
10     <target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
11       <target xsi:type="File" fileName="${basedir}/logs/${shortdate}.txt" layout="${longdate} ${level:uppercase=true} ${event-context:item=Action} ${message} ${event-context:item=Amount} ${stacktrace}" />
12     </target>
13 
14   </targets>
15 
16   <rules>
17     <logger name="*" minlevel="Info" writeTo="file" />
18   </rules>
19 
20 
21 </nlog>
View Code

相关文章:

  • 2021-10-20
  • 2022-12-23
  • 2018-05-24
  • 2021-09-26
  • 2021-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-05-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2021-10-24
  • 2022-12-23
相关资源
相似解决方案