分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

NetCore中使用NLog配置详解

发布时间:2023-09-06 02:23责任编辑:赖小花关键词:配置
<?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" ?????autoReload="true" ?????throwConfigExceptions="true" ?????????????internalLogLevel="info" ?????????????????????????????internalLogFile="E:\log\ISP\internal-nlog.txt"> ?<!--autoReload:修改后自动加载--> ?<!--throwConfigExceptions:NLog日志系统抛出异常--> ?<!--internalLogLevel:内部日志的级别--> ?<!--internalLogFile:内部日志保存路径,日志的内容大概就是NLog的版本信息,配置文件的地址等等--> ???<!-- the targets to write to --> ?<!--输出日志的配置,用于rules读取--> ?<targets> ???<!-- 将日志写入文件中 ?--> ???<target xsi:type="File" name="allfile" ????fileName="E:\log\ISP\nlog-all-${shortdate}.log" layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" /> ???<!--同样是将文件写入日志中,写入的内容有所差别,差别在layout属性中体现。写入日志的数量有差别,差别在路由逻辑中体现--> ???<target xsi:type="File" name="ownFile-web" fileName="E:\log\ISP\nlog-own-${shortdate}.log" layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action}|${callsite}" /> ?</targets> ?<!-- rules to map from logger name to target --> ?<rules> ???<!--路由顺序会对日志打印产生影响。路由匹配逻辑为顺序匹配。--> ???<!--All logs, including from Microsoft--> ???<logger name="*" minlevel="Trace" writeTo="allfile" /> ???<!--Skip non-critical Microsoft logs and so log only own logs--> ???<!--以Microsoft打头的日志将进入此路由,由于此路由没有writeTi属性,所有会被忽略--> ???<!--且此路由设置了final,所以当此路由被匹配到时。不会再匹配此路由下面的路由。未匹配到此路由时才会继续匹配下一个路由--> ???<logger name="Microsoft.*" maxlevel="Info" final="true" /> ???<!-- BlackHole --> ???<!--上方已经过滤了所有Microsoft.*的日志,所以此处的日志只会打印除Microsoft.*外的日志--> ???<logger name="*" minlevel="Trace" writeTo="ownFile-web" /> ?</rules></nlog>

NetCore中使用NLog配置详解

原文地址:https://www.cnblogs.com/Kevin-Ni/p/9995894.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved