I’ve been using NLog for a while now and recently decided I wanted to have some of my log files written as Unicode text. I learned that you can specify this in your <target> sections of NLog.config as follows:
1 <targets><br /> <!-- add your targets here --><br /> <target xsi:type="File" name="mainFile" fileName="${logFile}"<br /> archiveEvery="Day" archiveNumbering="Sequence" concurrentWrites="false" maxArchiveFiles="30"<br /> layout="${layout}" encoding="UTF-8" /><br /></targets>
Note that I only tested two different encodings, “Unicode” and “UTF-8”. Also, “UTF-8” must have the hyphen in it to work.
Rob
This post was migrated from https://blogs.msdn.microsoft.com/rob/2013/01/05/text-encoding-options-for-nlog/.