【发布时间】:2021-11-14 03:25:18
【问题描述】:
我正在尝试使用 nlog 将消息记录到文件中。我的问题是,每当我尝试将波兰字符用作“ąćęśł”时,它们在日志文件中显示为 ¹æê³。其他国家的特殊字符确实有效(如 ä ö 等)。可能是什么问题? 这就是我的 nlog.config 开头的样子:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info">
<targets>
<target
xsi:type="File"
name="allInfo"
fileName="${whenEmpty:whenEmpty=${basedir}:inner=${configsetting:item=PathToFiles}}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}"
archiveEvery="Month"
archiveFileName="${whenEmpty:whenEmpty=${basedir}:inner=${configsetting:item=PathToFiles}}/logs/archive/log-${shortdate}.log"
maxArchiveFiles="50"/>
</targets>
<rules>
<logger
name="*"
minlevel="Trace"
writeTo="allInfo"/>
</rules>
</nlog>
</configuration>
正如您所见,utf-8 就在那里。不知道如何解决。
【问题讨论】:
-
那是配置文件的编码,与配置nlog本身无关。请也显示文件的其余部分。
-
@AKX 编辑后的帖子
-
编码是
UTF8不是utf-8