NLog not Logging in Simple App

血红的双手。 提交于 2019-12-14 04:02:21

问题


I am trying to implement a simple log using Nlog 1.0, using the following code

  Dim _logger = LogManager.GetCurrentClassLogger()
  _logger.Debug("Iain")

And the following NLog.config.

<?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" >
  <targets>
      <target name="file" xsi:type="File" fileName="${basedir}/Site.log" layout="${date}: ${message}"/>
    <target name="eventlog" xsi:type="EventLog" source="My App" log="Application" layout="${date}: ${message} ${stacktrace}"/>
  </targets>
  <rules>
    <logger name="*" minlevel="Info" writeTo="file" />
    <logger name="*" minlevel="Fatal" writeTo="eventlog" />
  </rules>

</nlog>

The app just dosnt seem to be logging, any ideas?

Cheers

Iain


回答1:


The minLevel is not set to log Debug messages.

NLog levels are:

  • Fatal
  • Error
  • Warn
  • Info
  • Debug
  • Trace

When you have minLevel set to Info, it will only log Info and higher; Debug and Trace messages will not be logged.



来源:https://stackoverflow.com/questions/3919083/nlog-not-logging-in-simple-app

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