Nlog suddenly stopped creating log files on Linux, but it works on windows

﹥>﹥吖頭↗ 提交于 2020-01-07 04:35:41

问题


My application is pointing to .net core framework 1.1.1.

I have added NLog to my project.

NLog - 5.0.0-beta05

NLog.Config - 4.3.9

NLog.Extensions.Logging - 1.0.0-rtm-beta1

My NLog config file is as follows:

<target name="infoInstrumentation"
      xsi:type="File"
      concurrentWrites="false"
    archiveFileName="/home/ubuntu/Desktop/Logs/Punu/ServiceInstrumentation.${shortdate}.{##}.log"
      archiveAboveSize="1000000"
      archiveNumbering="Rolling"
      maxArchiveFiles="10"
      fileName="/home/ubuntu/Desktop/Logs/Punu/ServiceInstrumentation.${shortdate}.log"
      layout="Timestamp: ${date}${newline}${all-event-properties:format=[key]\: [value]:separator=\&#xD;&#xA;}${newline}Message: ${message}${newline}Machine: ${machinename}${newline}${newline}${LayoutFooter}"
      keepFileOpen="false">
    </target>

Logging works on windows, but when I test code on Linux, it fails to write. Few days before it was working with Linux, but now it has stopped completely.


回答1:


As it looks like a problem with NLog library, you may try to troubleshoot NLog. For example, you may enable NLog internal logging and check if there are any problems.

Modify NLog config: add the following attributes into <nlog> section

internalLogLevel="Warn"
internalLogFile="internal-nlog.txt"

Look into Logging-troubleshooting NLog wiki for more examples, especially read "Internal logging" section.

Maybe you have the same problem, discussed here (issue on github): Unable to create/write to log on linux server using NLog 5.0.0-beta01 + beta02




回答2:


Make sure your configuration filename is exactly "NLog.config". Other casing will work on Windows, but Linux has case-sensitive filenames.



来源:https://stackoverflow.com/questions/43875431/nlog-suddenly-stopped-creating-log-files-on-linux-but-it-works-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!