visual-studio-code - NLog 没有向控制台输出任何内容
问题描述
我正在关注本教程 https://www.youtube.com/watch?v=jn6X-rx78ZU&list=PLJFgzBCcspK8p7Hxu2OLh-f-x0PBsIGjH&index=15&ab_channel=TheTutorialChef 我正在尝试在最后运行服务器。NLog 应该输出到服务器已经启动的控制台,但是 NLog 没有输出任何东西。我在下面添加了 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">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<target name="Console" xsi:type="Console" layout=" ${level} ${date} ${message} ${exception:innerFormat=Message,StackTrace}" />
<!-- https://github.com/NLog/NLog/wiki/ColoredConsole-target -->
<target name="CConsole" useDefaultRowHighlightingRules="true" xsi:type="ColoredConsole" layout="${logger} ${level} ${date} ${message} ${exception:innerFormat=Message,StackTrace}" >
</target>
<target name="warnfile" xsi:type="File" fileName="${basedir}/Logs/warning.txt"
maxArchiveFiles="4"
archiveAboveSize="10240"
archiveEvery="Day" />
<target name="infofile" xsi:type="File" fileName="${basedir}/Logs/info.txt"
maxArchiveFiles="4"
archiveAboveSize="10240"
archiveEvery="Day" />
</targets>
<rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Info" maxlevel="Warn" writeTo="infofile" />
<logger name="*" minlevel="Warn" writeTo="warnfile" />
<logger name="*" minlevel="Trace" writeTo="CConsole" />
</rules>
</nlog>
但没有任何输出。没有编译错误或警告。我做错了什么?我正在使用 VSCode 2017 和 NLog 4.7.6。我试过直接编辑 .nuget 包中的 cofig 文件。我尝试重新安装 NLog 以获取原始 NLog.config,但是现在当我重新安装 NLog 时,配置文件不再出现在根目录中。
解决方案
推荐阅读
- ios - SwiftUI - 如何从 VStack 中的函数运行另一个结构的协调器的代码?
- php - PHP-FPM 生成的字节顺序标记 (BOM)
- r - 在 R Dataframe 中修改转置
- reactjs - useEffect 无限循环,即使我提供了依赖项列表
- javascript - 如何根据请求在 iframe 中加载不同的页面(HTML、JS、Flask)
- php - 检查数据库中是否存在记录,发送电子邮件并重定向到 Laravel 7.x 中的输入令牌页面
- linux-kernel - 在 QEMU 中支持多个 edu 设备
- python - 将整数附加到字典键,python
- amazon-web-services - 我有弹性 beantalk 的 nginx client_max_body_size 设置问题
- java - 创建 switch 语句以将 Color 类数据类型转换为 String 类型