log4net.config 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <configSections>
  4. <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  5. </configSections>
  6. <log4net>
  7. <!-- 定义输出到文件中 -->
  8. <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  9. <!--定义文件存放位置-->
  10. <file value="logs\\"/>
  11. <appendToFile value="true"/>
  12. <rollingStyle value="Date"/>
  13. <datePattern value="yyyy-MM-dd'.txt'"/>
  14. <staticLogFileName value="false"/>
  15. <!--日志最大可备份数-->
  16. <maxSizeRollBackups value="100"/>
  17. <!--日志文件大小-->
  18. <maximumFileSize value="1024KB"/>
  19. <layout type="log4net.Layout.PatternLayout">
  20. <!--每条日志末尾的文字说明-->
  21. <!--输出格式-->
  22. <!--样例:2008-03-26 13:42:32,111 [10] INFO Log4NetDemo.MainClass [(null)] - info-->
  23. <conversionPattern value="%newline %n记录时间:%date %n线程ID:[%thread] %n日志级别: %-5level %n出错类:%logger property: [%property{NDC}] - %n错误描述:%message%newline %n"/>
  24. </layout>
  25. </appender>
  26. <root>
  27. <level value="DEBUG"/>
  28. <!--文件形式记录日志-->
  29. <appender-ref ref="RollingLogFileAppender"/>
  30. </root>
  31. </log4net>
  32. </configuration>