NetCore使用Nlog记录日志
2021-01-27 05:14
标签:ext 记录 OLE core soft filename trace int none 当前环境: win10+vs2019+netcore3.1 添加Nuget包引用:NLog.Web.AspNetCore 2. 添加 nlog.config配置文件 或者安装包 nlog.confg 3. 在CreateHostBuilder 中添加使用Nlog ( ConfigureLogging) 4. 配置文件路径 5. 调用 6. 效果 在bin\Debug\netcoreapp3.1 目录下生成了logs文件夹 NetCore使用Nlog记录日志 标签:ext 记录 OLE core soft filename trace int none 原文地址:https://www.cnblogs.com/wtujvk/p/13222233.htmlxml 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"
autoReload="true"
internalLogLevel="Info"
internalLogFile="c:\temp\internal-nlog.txt">
extensions>
add assembly="NLog.Web.AspNetCore"/>
extensions>
targets>
target xsi:type="File" name="allfile" fileName="logs\nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />
target xsi:type="File" name="ownFile-web" fileName="logs\nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}" />
targets>
rules>
logger name="*" minlevel="Trace" writeTo="allfile" />
logger name="Microsoft.*" maxlevel="Info" final="true" />
logger name="*" minlevel="Trace" writeTo="ownFile-web" />
rules>
nlog>
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup
NLog.Web.NLogBuilder.ConfigureNLog("nlog.config")
public class HomeController : Controller
{
private readonly ILogger
上一篇:用户变焦 | @viewport.user-zoom (Device Adaptation) - CSS 中文开发手册 - Break易站
下一篇:缩放背景图像 | CSS Background and Borders: Scaling background images (Backgrounds & Borders) - CSS 中文开