Logging Persian messages with NLog(使用NLog记录波斯语消息)
问题描述
在我的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"
属性
这篇关于使用NLog记录波斯语消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!