nlog.config一段时间后不编写日志

发布于 2025-01-27 01:33:35 字数 1946 浏览 1 评论 0原文

我正在遇到NLOG的问题,没有将日志写入配置文件中提到的文件夹。这是针对我们实施的Windows服务。每当我们启动服务时,它都会写几天/小时的日志。但是突然间,它停止写日志。我们再次需要重新启动服务以解决该问题,并再次重复问题。

请在下面找到NLOG配置文件,并真正感谢任何解决问题的帮助。

<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
  <targets async="true">
    <target name="ApplicationLog" xsi:type="File" layout="&lt;LogEntry&gt;&lt;Date&gt;${longdate}&lt;/Date&gt;&lt;Level&gt;${level}&lt;/Level&gt;&lt;Message&gt;${message}&lt;/Message&gt;&lt;StackDump&gt;${stacktrace}&lt;/StackDump&gt;&lt;Exception&gt;${exception:format=ToString}&lt;/Exception&gt;&lt;/LogEntry&gt;" fileName="D:\ApplicationLogs\Account\account.txt" encoding="iso-8859-2" archiveFileName="D:\ApplicationLogs\Account\Archive\account.{########}.txt" archiveNumbering="Rolling" archiveEvery="Day" archiveAboveSize="20971520" maxArchiveFiles="60" />
    <target name="securityLog" xsi:type="File" layout="&lt;LogEntry&gt;&lt;Date&gt;${longdate}&lt;/Date&gt;&lt;Level&gt;${level}&lt;/Level&gt;&lt;Message&gt;${message}&lt;/Message&gt;&lt;StackDump&gt;${stacktrace}&lt;/StackDump&gt;&lt;Exception&gt;${exception:format=ToString}&lt;/Exception&gt;&lt;/LogEntry&gt;" fileName="D:\ApplicationLogs\Account\securityLog.txt" encoding="iso-8859-2" archiveFileName="D:\ApplicationLogs\Account\Archive\securityLog.{########}.txt" archiveNumbering="Rolling" archiveEvery="Day" archiveAboveSize="20971520" maxArchiveFiles="60" />
  </targets>
  <rules>
    <logger name="*" minlevel="Info" writeTo="securityLog" />
    <logger name="*" minlevel="Info" writeTo="ApplicationLog" />
  </rules>
</nlog>

谢谢

I am having an issue with Nlog not writing logs to the folder mentioned in the config file. This is for windows service we implemented. Whenever we start a service, it writes the logs for few days/hours. But all off a sudden it stops writing the logs. We again needs to restart the service to resolve the issue and issues repeats again.

Please find below the nlog config file and any help to resolve the issue is really appreciated.

<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
  <targets async="true">
    <target name="ApplicationLog" xsi:type="File" layout="<LogEntry><Date>${longdate}</Date><Level>${level}</Level><Message>${message}</Message><StackDump>${stacktrace}</StackDump><Exception>${exception:format=ToString}</Exception></LogEntry>" fileName="D:\ApplicationLogs\Account\account.txt" encoding="iso-8859-2" archiveFileName="D:\ApplicationLogs\Account\Archive\account.{########}.txt" archiveNumbering="Rolling" archiveEvery="Day" archiveAboveSize="20971520" maxArchiveFiles="60" />
    <target name="securityLog" xsi:type="File" layout="<LogEntry><Date>${longdate}</Date><Level>${level}</Level><Message>${message}</Message><StackDump>${stacktrace}</StackDump><Exception>${exception:format=ToString}</Exception></LogEntry>" fileName="D:\ApplicationLogs\Account\securityLog.txt" encoding="iso-8859-2" archiveFileName="D:\ApplicationLogs\Account\Archive\securityLog.{########}.txt" archiveNumbering="Rolling" archiveEvery="Day" archiveAboveSize="20971520" maxArchiveFiles="60" />
  </targets>
  <rules>
    <logger name="*" minlevel="Info" writeTo="securityLog" />
    <logger name="*" minlevel="Info" writeTo="ApplicationLog" />
  </rules>
</nlog>

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文