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.
 
 
 

48 lines
3.7 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/internalLog.txt"
  17. internalLogLevel="Debug" >
  18. <variable name="Directory" value="/data/logs/JT1078.Gateway"/>
  19. <targets>
  20. <target name="all" xsi:type="File"
  21. fileName="${Directory}/all/${shortdate}.log"
  22. layout="${date:format=yyyyMMddHHmmss} ${callsite} ${level}:${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}"/>
  23. <target name="JT1078TcpMessageHandlers" xsi:type="File"
  24. fileName="${Directory}/JT1078TcpMessageHandlers/${shortdate}.log"
  25. layout="${date:format=yyyyMMddHHmmss},${message}"/>
  26. <target name="JT1078TcpMessageHandlersHex" xsi:type="File"
  27. fileName="${Directory}/JT1078TcpMessageHandlersHex/${shortdate}.log"
  28. layout="${date:format=yyyyMMddHHmmss},${message}"/>
  29. <target name="JT1078TcpConnectionHandler" xsi:type="File"
  30. fileName="${Directory}/JT1078TcpConnectionHandler/${shortdate}.log"
  31. layout="${date:format=yyyyMMddHHmmss},${message}"/>
  32. <target name="console" xsi:type="ColoredConsole"
  33. useDefaultRowHighlightingRules="false"
  34. layout="${date:format=yyyyMMddHHmmss} ${callsite} ${level} ${message} ${onexception:${exception:format=tostring} ${newline} ${stacktrace} ${newline}">
  35. <highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
  36. <highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
  37. <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
  38. <highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
  39. <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
  40. </target>
  41. </targets>
  42. <rules>
  43. <logger name="*" minlevel="Error" maxlevel="Fatal" writeTo="all"/>
  44. <logger name="JT1078.DotNetty.Tcp.Handlers.JT1078TcpConnectionHandler" minlevel="Debug" maxlevel="Fatal" writeTo="JT1078TcpConnectionHandler,console"/>
  45. <logger name="JT1078TcpMessageHandlers" minlevel="Debug" maxlevel="Fatal" writeTo="JT1078TcpMessageHandlers"/>
  46. <logger name="JT1078TcpMessageHandlersHex" minlevel="Debug" maxlevel="Fatal" writeTo="JT1078TcpMessageHandlersHex"/>
  47. </rules>
  48. </nlog>