NLog.confg 参考配置, 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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> <variable name="logDirectory" value="${basedir}/logs"/>
<variable name="traceVal" value="${date:format=HH\:mm\:ss} [Thread-${threadname:whenEmpty=${threadid}}]|${message}"/>
<variable name="layoutVal" value="${date:format=HH\:mm\:ss} [Thread-${threadname:whenEmpty=${threadid}}]|${uppercase:${level}}|${callsite:fileName=True}${newline}${message}${newline}${exception}"/>
<variable name="consoleVal" value="${date:format=HH\:mm\:ss}|${pad:padding=5:inner=${level:uppercase=true}}|${message}"/> <targets>
<target name="console" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false"
layout="${consoleVal}" >
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target> <target xsi:type="File"
name="logfile"
fileName="${logDirectory}/info_${shortdate}.log"
keepFileOpen="false"
layout="${layoutVal}" />
<target xsi:type="File"
name="warnfile"
fileName="${logDirectory}/warn_${shortdate}.log"
keepFileOpen="false"
layout="${layoutVal}" />
<target xsi:type="File"
name="errfile"
fileName="${logDirectory}/error_${shortdate}.log"
keepFileOpen="false"
layout="${layoutVal}" />
<target xsi:type="File"
name="debugfile"
fileName="${logDirectory}/debug_${shortdate}.log"
keepFileOpen="false"
layout="${layoutVal}" />
<target xsi:type="File"
name="tracefile"
fileName="${logDirectory}/trace_${shortdate}.log"
keepFileOpen="false"
layout="${traceVal}" />
</targets> <rules>
<logger name="*" writeTo="console" />
<logger name="*" level="Trace" writeTo="tracefile"/>
<logger name="*" level="Error" writeTo="errfile" />
<logger name="*" level="Warn" writeTo="warnfile"/>
<logger name="*" minlevel="Info" writeTo="logfile"/>
<logger name="*" minlevel="Debug" writeTo="debugfile" />
</rules>
</nlog>

NLog.config 配置的更多相关文章

  1. .Net项目中NLog的配置与使用

    引言: 因为之前在项目开发中一直都是使用的Log4Net作为项目的日志记录框架,最近忽然感觉对它已经有点腻了,所以尝试着使用了NLog作为新项目的日志记录框架(当然作为一名有志向的攻城狮永远都不能只局 ...

  2. NLog简单配置与使用

    对项目添加NLog 安装完成后,在项目里面会自动引入该引入的dll,并且会添加如下两个文件 NLog的配置主要是在这个config文件里.当然也可以将这个文件里面的nlog节点复制到项目配置文件App ...

  3. Net Core 2.1 日志记录框架NLog+Mysql配置

    NLog是什么? 这里还是简单介绍一下吧,为了让小白也知道.NLog是一个灵活的免费日志记录平台,适用于各种.NET平台,包括.NET Core.NLog可以通过简单地配置就可以可以很方便的写入多个日 ...

  4. NetCoreApi框架搭建(二、Nlog使用配置)

    本文只配置了简单文件存储 1.添加nuget包 2.添加日志配置文件nlog.config 这里配置了三个target区分不同的日志,具体配置需要自己研究,推荐链接https://www.cnblog ...

  5. Asp.NetCore Web开发之Nlog日志配置

    接着讲基于ASP .net Core 的web开发,这节主要讲一下如何使用和配置Nlog进行日志记录. 日志在开发中的作用是很重要的,使用日志,程序出了错误可以及时捕获并记录下来,开发人员可以通过日志 ...

  6. Web.config配置数据库连接

    web.config配置数据库连接   第一种:取连接字符串 string connString = System.Web.Configuration.WebConfigurationManager. ...

  7. Asp.net Web.Config - 配置元素 caching

    Asp.net Web.Config - 配置元素 caching 记得之前在写缓存DEMO的时候,好像配置过这个元素,好像这个元素还有点常用. 一.caching元素列表   元素 说明 cache ...

  8. asp.net中web.config配置节点大全详解

    最近网上找了一些关于Web.config配置节点的文章,发现很多都写的都比较零散,而且很少有说明各个配置节点的作用和用法.搜索了一下发现有一篇写的不错,这里引用一下 原文地址 http://www.c ...

  9. 十五天精通WCF——第二天 告别烦恼的config配置

    经常搞wcf的基友们肯定会知道,当你的应用程序有很多的“服务引用”的时候,是不是有一种疯狂的感觉...从一个环境迁移到另外一个环境,你需要改变的 endpoint会超级tmd的多,简直就是搞死了人.. ...

  10. 转:NLog 自定义日志内容,写日志到数据库;修改Nlog.config不起作用的原因

    转:http://www.cnblogs.com/tider1999/p/4308440.html NLog的安装请百度,我安装的是3.2.NLog可以向文件,数据库,邮件等写日志,想了解请百度,这里 ...

随机推荐

  1. JUC并发编程学习(十三)ForkJoin

    ForkJoin 什么是ForkJoin ForkJoin在JDK1.7,并发执行任务!大数据量时提高效率. 大数据:Map Reduce(把大任务拆分成小任务) ForkJoin特点:工作窃取 为什 ...

  2. (Good topic)压缩字符串 (3.16 leetcode每日打卡)

    字符串压缩.利用字符重复出现的次数,编写一种方法,实现基本的字符串压缩功能.比如,字符串aabcccccaaa会变为a2b1c5a3.若"压缩"后的字符串没有变短,则返回原先的字符 ...

  3. 深入理解 BigBird 的块稀疏注意力

    引言 基于 transformer 的模型已被证明对很多 NLP 任务都非常有用.然而,\(O(n^2)\) 的时间和内存复杂度 (其中 \(n\) 是序列长度) 使得在长序列 (\(n > 5 ...

  4. C++ 共享内存ShellCode跨进程传输

    在计算机安全领域,ShellCode是一段用于利用系统漏洞或执行特定任务的机器码.为了增加攻击的难度,研究人员经常探索新的传递ShellCode的方式.本文介绍了一种使用共享内存的方法,通过该方法,两 ...

  5. 将mysql的输出文本写回mysql

    1 准备工作 1.1 环境准备 操作系统:Microsoft Windows 10 专业工作站版 软件版本:Python 3.9.6 第三方包: pip install pandas2.1.0 pip ...

  6. [NOI online2022普及A] 王国比赛

    题目描述 智慧之王 Kri 统治着一座王国. 这天 Kri 决定举行一场比赛,来检验自己大臣的智慧. 比赛由 \(n\) 道判断题组成,有 \(m\) 位大臣参加.现在你已经知道了所有大臣的答题情况, ...

  7. [CF1748E] Yet Another Array Counting Problem

    题目描述 The position of the leftmost maximum on the segment $ [l; r] $ of array $ x = [x_1, x_2, \ldots ...

  8. windows查看GPU信息(nvidia-smi)

    一般在使用windows系统的电脑时,想要了解GPU的使用情况时,我们通常会打开任务管理器去查看.但是这种方式一般只能看到简单的情况.那么我们想要了解更多的情况的话,该怎么办呢.可以在cmd中输入nv ...

  9. 玩转Spring状态机

    说起Spring状态机,大家很容易联想到这个状态机和设计模式中状态模式的区别是啥呢?没错,Spring状态机就是状态模式的一种实现,在介绍Spring状态机之前,让我们来看看设计模式中的状态模式. 1 ...

  10. python tkinter使用(九)

    python tkinter使用(九) 本文主要讲下scrolledText中图片的插入,以及常见的错误. 使用Image.open来打开图片 使用ImageTk.PhotoImage()方法将图片转 ...