NLog配置分享
新建一个文件命名为NLog.Config,然后添加如下代码
<?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">
<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target name="log_file" xsi:type="File"
fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt"
layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}"
archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt"
archiveAboveSize="102400"
archiveNumbering="Sequence"
concurrentWrites="true"
keepFileOpen="false" />
</target>
<target name="console" xsi:type="ColoredConsole" layout="[${date:format=HH\:mm\:ss}]:${message} ${exception:format=message}" />
</targets>
<rules>
<logger name="*" minlevel="Error" writeTo="asyncFile" />
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</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="logLayout"
value="Logger:${logger}${newline}Date:${longdate} Level:${uppercase:${level}}${newline}Message:${message} ${newline}${onexception:Exception:${exception:format=toString}${newline}}" />
<targets>
<target name="asyncFile" xsi:type="AsyncWrapper">
<target name="log_file" xsi:type="File"
fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt"
layout="${logLayout}"
archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt"
archiveAboveSize="102400"
archiveNumbering="Sequence"
concurrentWrites="false"
keepFileOpen="true"
encoding="utf-8"
openFileCacheTimeout="30"/>
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="asyncFile" />
</rules>
</nlog>
NLog配置分享的更多相关文章
- lnmp架构下php安全配置分享
目录[-] 1. 使用open_basedir限制虚拟主机跨目录访问 2. 禁用不安全PHP函数 3. 关注软件安全资讯 4. php用户只读 5. 关闭php错误日志 6. php上传分离 7. 关 ...
- ASP.NET Core根据环境切换NLog配置
1.新建NLog配置文件,名称分别为nlog.config和nlog.debug.config <?xml version="1.0"?> <nlog xmlns ...
- Nlog配置
初次使用nlog,里里外外找了好久,终于搞会了. 使用nlog建日志输出到txt文件.数据库.邮件 nlog配置,如图 码云dome
- Vue使用Echarts以及Echarts配置分享
一.本篇文章将给大家分享如何在vue中使用echart以及echart各项配置,这些配置都是工作中比较常见以及常用到的,所以给大家分享下,希望对大家有用. 二.vue中使用echart. 1.首先下载 ...
- NLog 配置
之前我介绍过如何使用log4net来记录日志,但最近喜欢上了另一个简单好用的日志框架NLog. 关于NLog和log4net的比较这里就不多讨论了,感兴趣的朋友可以参看.NET日志工具介绍和log4n ...
- NLog 配置与使用
有段时间没写博客了,过年放假,一直在弄CMS.什么都自己写了一遍,今天写写NLog,之前一用的log4net,感觉配置起来还是有些麻烦. NuGet 添加组件 配置 NLog.config <? ...
- Nlog配置实例
彩色Console target <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns= ...
- Nlog 配置总结
Writes log messages to one or more files. Since NLog 4.3 the ${basedir} isn't needed anymore for rel ...
- vim配置分享(持续更新中)
作者:zhanhailiang 日期:2014-10-24 set nocompatible set nu "" 自己主动缩进 syntax on set autoindent ...
随机推荐
- Python笔记(十六):迭代器
(一)iterable对象和Iterator对象的区别 iterable对象(可迭代的对象):可以使用for循环,例如:字符串.列表 .字典 .集合等 Iterator对象(迭代器):除了可以用for ...
- element-ui 2.4.8 BUG 标签页的最后一个Tab标题没法移除,更新后发现最新版本不存在该问题了 记录下
- Android长时间定时任务实现
在服务的onStartCommand方法里面使用AlarmManager 定时唤醒发送广播,在广播里面启动服务 每次执行startService方法启动服务都会执行onStartCommand 1.服 ...
- Android Studio无线连调式android手机
两种方法: 一.打开命令行或者Terminal窗口, 运行 adb connect 192.168.10.163:5555 来通过wifi连接手机调试 IP地址查看手机wifi的ip 要求手机和 ...
- c/c++赋值函数(重载=号运算符)
c/c++赋值函数(重载=号运算符) 首先c++里的各种运算符都是用函数实现的,比如=,就等号函数. 所以当用=给一个对象赋值的时候,实际调用的是=号所对应的=号函数. 分析下面的代码 #includ ...
- MySQL常用命令(一)
(1)库的基础操作 查看已有库: show databases; 创建库(制定默认字符集): ccreate database 库名 default charset=utf8; 查看创建库的语句: s ...
- win10同时安装 office2016和visio2016
一.下载镜像文件 因为office 2016和 visio2016 镜像文件是一样的,只是名称不一样,所以只需要下载一个即可. 二.下载Office 2016 Deployment Tool工具 到微 ...
- Excel 单元格不能设置超链接
最近在重做系统后 新安装office后 原先的Excel中设置的超链接不能正常使用了 如果新配置的超链接也不能使用 解决方法: 步骤1:打开开始菜单,在运行里输入regedit,回车 步骤2 在 ...
- LeetCode算法题-Merge Sorted Array(Java实现)
这是悦乐书的第161次更新,第163篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第20题(顺位题号是88).给定两个排序的整数数组nums1和nums2,将nums2中 ...
- python 浅谈小数据池和编码
⼀. ⼩数据池 在说⼩数据池之前. 我们先看⼀个概念. 什么是代码块: 根据提示我们从官⽅⽂档找到了这样的说法: A Python program is constructed from code b ...