在我的ASP.NET MVC项目中,如下所示在Web.config中具有以下配置:
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="default" xsi:type="File" fileName="logs/app-log.txt" layout="
--------------------- ${level} (${longdate}) ----------------------$
IP: ${aspnet-request-ip}
Call Site: ${callsite}
${level} message: ${message}"/> archiveFileName="logs/archives/app-log.{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" />
</targets>
<rules>
<logger name="*" writeTo="default" />
</rules>
</nlog>
如果我的日志消息是波斯文字,那么在日志文件中,我将问号标记为?????
,而不是波斯文字。
如何解决此问题?任何帮助将不胜感激!
我在目标元素中添加了encoding="UTF8"
属性
正如@ramesh用Encoding="utf-16"
指出tru并尝试writeBom="true"
。