You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
2.8 KiB

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!--
  3. 参考:http://www.cnblogs.com/fuchongjundream/p/3936431.html
  4. autoReload:自动再配置
  5. internalLogFile:可以让NLog把内部的调试和异常信息都写入指定文件里程序没问题了,日志却出了问题。这个该怎么办,到底是哪里不正确了?假如日志本身除了bug该如何解决?这就需要日志排错。把日志的错误信息写入日志。
  6. <nlog throwExceptions="true" />
  7. <nlog internalLogFile="file.txt" />- 设置internalLogFile属性可以让NLog把内部的调试和异常信息都写入指定文件里。
  8. <nlog internalLogLevel="Trace|Debug|Info|Warn|Error|Fatal" /> - 决定内部日志的级别,级别越高,输出的日志信息越简洁。
  9. <nlog internalLogToConsole="false|true" /> - 是否把内部日志输出到标准控制台。
  10. <nlog internalLogToConsoleError="false|true" /> - 是否把内部日志输出到标准错误控制台 (stderr)。
  11. 设置throwExceptions属性为“true”可以让NLog不再阻挡这类异常,而是把它们抛给调用者。在部署是这样做可以帮我们快速定位问题。一旦应用程序已经正确配置了,我们建议把throwExceptions的值设为“false”,这样由于日志引发的问题不至于导致应用程序的崩溃。
  12. -->
  13. <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
  14. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  15. autoReload="true"
  16. internalLogFile="wwwroot/logs/JT808.Gateway/internalLog.txt"
  17. internalLogLevel="Debug" >
  18. <variable name="Directory" value="/data/logs/JT808.Gateway"/>
  19. <targets>
  20. <target name="Gateway" xsi:type="File"
  21. fileName="${Directory}/Gateway.${shortdate}.log"
  22. layout="${date:format=yyyyMMddHHmmss} ${callsite} ${level}:${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"/>
  23. <target name="console" xsi:type="ColoredConsole"
  24. useDefaultRowHighlightingRules="false"
  25. layout="${date:format=yyyyMMddHHmmss} ${callsite} ${level} ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}">
  26. <highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
  27. <highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
  28. <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
  29. <highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
  30. <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
  31. </target>
  32. </targets>
  33. <rules>
  34. <logger name="*" minlevel="Trace" maxlevel="Fatal" writeTo="Gateway,console"/>
  35. </rules>
  36. </nlog>