NLog.config 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
  5. autoReload="true"
  6. throwExceptions="false"
  7. internalLogLevel="Warn"
  8. internalLogFile="Logs/nlog-internal.log">
  9. <!--internalLogLevel="Off"-->
  10. <!-- optional, add some variables
  11. https://github.com/nlog/NLog/wiki/Configuration-file#variables
  12. -->
  13. <variable name="myvar" value="myvalue"/>
  14. <!--
  15. See https://github.com/nlog/nlog/wiki/Configuration-file
  16. for information on customizing logging rules and outputs.
  17. -->
  18. <targets>
  19. <!--
  20. add your targets here
  21. See https://github.com/nlog/NLog/wiki/Targets for possible targets.
  22. See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
  23. -->
  24. <!--
  25. Write events to a file with the date in the filename.
  26. <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
  27. layout="${longdate} ${uppercase:${level}} ${message}" />
  28. -->
  29. <!-- write logs to file -->
  30. <target xsi:type="File" name="allfile" fileName="logs/${date:format=yyyy-MM-dd}/log.txt"
  31. layout="------------------------------------------${newline}${longdate} | ${uppercase:${level}} | ${logger} ${newline}${message} ${exception} ${newline} " />
  32. <target xsi:type="Null" name="blackhole" />
  33. </targets>
  34. <rules>
  35. <!-- add your logging rules here -->
  36. <!--
  37. Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
  38. <logger name="*" minlevel="Debug" writeTo="f" />
  39. -->
  40. <!--All logs, including from Microsoft-->
  41. <!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
  42. <logger name="*" minlevel="Error" maxlevel="Fatal" writeTo="allfile" />
  43. <!--Skip Microsoft logs and so log only own logs-->
  44. <logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
  45. <!--<logger name="*" minlevel="Trace" writeTo="ownFile-web" />-->
  46. <!--<logger name="*" minlevel="Fatal" writeTo="database" />-->
  47. </rules>
  48. </nlog>