输出日志到RichTextBox
添加引用
新建一个windows窗体应用程序后
在项目中引用NLog和NLog.Windows.Forms
在Form界面添加RichTextBox用以日志输出。
配置NLog.config
新建NLog.config文件。内容如下。
该配置支持输出到文件和RichTextBox。
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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name=