log4net.config 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. <!-- Agv日志文件-->
  8. <appender name="InfoFileAppender" type="log4net.Appender.RollingFileAppender">
  9. <!-- RollingFileAppender以FileAppender为基础 -->
  10. <File value="Log\InfoLog" />
  11. <!--<file value="${TMP}\LOGS\" /> tmp为环境变量里的路径值,未配置环境变量地址就生成在temp中,log-file.txt为文件名 -->
  12. <param name="AppendToFile" value="true" />
  13. <!-- 指定是追加到还是覆盖掉已有的日志文件 -->
  14. <!--<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />-->
  15. <param name="lockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
  16. <!-- 启用最小锁定格式以允许多个进程可以写入同一个文件-->
  17. <param name="RollingStyle" value="Composite" />
  18. <!--按照何种方式产生多个日志文件(指明文件名是变动的,日期[Date],文件大小[Size],混合[Composite])-->
  19. <StaticLogFileName value="false" />
  20. <DatePattern value="yyyy\\MM\\dd\\yyyy-MM-dd'.txt'" />
  21. <MaxSizeRollBackups value="-1" />
  22. <!-- 最多个数为-1无限个-->
  23. <MaximumFileSize value="2MB" />
  24. <layout type="log4net.Layout.PatternLayout">
  25. <conversionPattern value="时间:%date___描述:%message%newline" />
  26. </layout>
  27. </appender>
  28. <!-- 报警日志文件 -->
  29. <appender name="AlarmInfoFileAppender" type="log4net.Appender.RollingFileAppender">
  30. <!-- RollingFileAppender以FileAppender为基础 -->
  31. <File value="Log\AlarmInfo" />
  32. <!--<file value="${TMP}\LOGS\" /> tmp为环境变量里的路径值,未配置环境变量地址就生成在temp中,log-file.txt为文件名 -->
  33. <param name="AppendToFile" value="true" />
  34. <!-- 指定是追加到还是覆盖掉已有的日志文件 -->
  35. <!--<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />-->
  36. <param name="lockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
  37. <!-- 启用最小锁定格式以允许多个进程可以写入同一个文件-->
  38. <param name="RollingStyle" value="Composite" />
  39. <!--按照何种方式产生多个日志文件(指明文件名是变动的,日期[Date],文件大小[Size],混合[Composite])-->
  40. <StaticLogFileName value="false" />
  41. <DatePattern value="yyyy\\MM\\dd\\CSV_yyyy-MM-dd'.txt'" />
  42. <MaxSizeRollBackups value="-1" />
  43. <!-- 最多个数为-1无限个-->
  44. <MaximumFileSize value="2MB" />
  45. <layout type="log4net.Layout.PatternLayout">
  46. <conversionPattern value="时间:%date___描述:%message%newline" />
  47. </layout>
  48. </appender>
  49. <!-- 运行错误日志文件 -->
  50. <appender name="ErrFileAppender" type="log4net.Appender.RollingFileAppender">
  51. <!-- RollingFileAppender以FileAppender为基础 -->
  52. <File value="Log\ErrInfo" />
  53. <!--<file value="${TMP}\LOGS\" /> tmp为环境变量里的路径值,未配置环境变量地址就生成在temp中,log-file.txt为文件名 -->
  54. <param name="AppendToFile" value="true" />
  55. <!-- 指定是追加到还是覆盖掉已有的日志文件 -->
  56. <!--<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />-->
  57. <param name="lockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
  58. <!-- 启用最小锁定格式以允许多个进程可以写入同一个文件-->
  59. <param name="RollingStyle" value="Composite" />
  60. <!--按照何种方式产生多个日志文件(指明文件名是变动的,日期[Date],文件大小[Size],混合[Composite])-->
  61. <StaticLogFileName value="false" />
  62. <DatePattern value="yyyy\\MM\\dd\\CSV_yyyy-MM-dd'.txt'" />
  63. <MaxSizeRollBackups value="-1" />
  64. <!-- 最多个数为-1无限个-->
  65. <MaximumFileSize value="2MB" />
  66. <layout type="log4net.Layout.PatternLayout">
  67. <conversionPattern value="时间:%date___描述:%message%newline" />
  68. </layout>
  69. </appender>
  70. <logger name="LogInfo">
  71. <level value="INFO" />
  72. <appender-ref ref="InfoFileAppender" />
  73. </logger>
  74. <logger name="AlarmLogInfo">
  75. <level value="WARN" />
  76. <appender-ref ref="AlarmInfoFileAppender" />
  77. </logger>
  78. <logger name="ErrLogInfo">
  79. <level value="ERROR" />
  80. <appender-ref ref="ErrFileAppender" />
  81. </logger>
  82. </log4net>
  83. </configuration>
  84. <!-- log4net-警告的信息级别区分 -->
  85. <!--<appender name="AspNetTraceAppender" type="log4net.Appender.AspNetTraceAppender" >
  86. <layout type="log4net.Layout.PatternLayout">
  87. <conversionPattern value="%n==========
  88. %n【日志级别】%-5level
  89. %n【记录时间】%date
  90. %n【线程ID】[%thread]
  91. %n【出错文件】%F
  92. %n【出错行号】%L
  93. %n【出错的类】%logger 属性:[%property{NDC}]
  94. %n【错误描述】%message
  95. %n【错误详情】%newline" />
  96. </layout>
  97. </appender>-->
  98. <!-- log4net-消息缓冲区配置(将日志信息进行缓存,达到10条时把日志输出,只有WARN及更高级别时才会被记录 ) -->
  99. <!--<appender name="BufferingForwardingAppender" type="log4net.Appender.BufferingForwardingAppender" >
  100. <bufferSize value="5"/>
  101. <lossy value="true" />
  102. <evaluator type="log4net.Core.LevelEvaluator">
  103. <threshold value="WARN"/>
  104. </evaluator>
  105. <appender-ref ref="ConsoleAppender" />
  106. </appender>-->
  107. <!--log4net-ERROR消息打印到控制台_红底白字-->
  108. <!--<appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
  109. <mapping>
  110. <level value="ERROR" />
  111. <foreColor value="White" />
  112. <backColor value="Red, HighIntensity" />
  113. </mapping>
  114. <mapping>
  115. <level value="WARN" />
  116. <foreColor value="Yellow" />
  117. </mapping>
  118. <mapping>
  119. <level value="INFO" />
  120. <foreColor value="White" />
  121. </mapping>
  122. <mapping>
  123. <level value="DEBUG" />
  124. <backColor value="Green" />
  125. </mapping>
  126. <layout type="log4net.Layout.PatternLayout">
  127. <conversionPattern value="%n==========
  128. %n【日志级别】%-5level
  129. %n【记录时间】%date
  130. %n【线程ID】[%thread]
  131. %n【出错文件】%F
  132. %n【出错行号】%L
  133. %n【出错的类】%logger 属性:[%property{NDC}]
  134. %n【错误描述】%message
  135. %n【错误详情】%newline" />
  136. </layout>
  137. </appender>-->
  138. <!-- log4net-将日志消息定向到控制台错误流 -->
  139. <!--<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
  140. <target value="Console.Error" />
  141. <layout type="log4net.Layout.PatternLayout">
  142. <conversionPattern value="%n==========
  143. %n【日志级别】%-5level
  144. %n【记录时间】%date
  145. %n【线程ID】[%thread]
  146. %n【出错文件】%F
  147. %n【出错行号】%L
  148. %n【出错的类】%logger 属性:[%property{NDC}]
  149. %n【错误描述】%message
  150. %n【错误详情】%newline" />
  151. </layout>
  152. </appender>-->
  153. <!-- log4net-将日志写入本地机器的应用程序事件日志中 -->
  154. <!--<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
  155. <applicationName value="MyApp" />
  156. <layout type="log4net.Layout.PatternLayout">
  157. <conversionPattern value="%n==========
  158. %n【日志级别】%-5level
  159. %n【记录时间】%date
  160. %n【线程ID】[%thread]
  161. %n【出错文件】%F
  162. %n【出错行号】%L
  163. %n【出错的类】%logger 属性:[%property{NDC}]
  164. %n【错误描述】%message
  165. %n【错误详情】%newline" />
  166. </layout>
  167. </appender>-->
  168. <!-- 向指定网络sink发送日志 -->
  169. <!--<appender name="RemotingAppender" type="log4net.Appender.RemotingAppender" >
  170. <sink value="tcp://localhost:8085/LoggingSink" />
  171. <lossy value="true" />
  172. <bufferSize value="95" />
  173. <onlyFixPartialEventData value="true" />
  174. <evaluator type="log4net.Core.LevelEvaluator">
  175. <threshold value="ERROR"/>
  176. </evaluator>
  177. </appender>-->
  178. <!-- 向指定邮箱发送日志 -->
  179. <!--<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender,log4net">
  180. <to value="***@qq.com" />
  181. <from value="840937370@qq.com" />
  182. <username value="840937370@qq.com" />
  183. -->
  184. <!--为客户端授权码-->
  185. <!--
  186. <password value="***********" />
  187. <subject value="B2P主控中心Error警告" />
  188. <smtpHost value="SMTPServer.qq.com" />
  189. <bufferSize value="512" />
  190. -->
  191. <!-- 大小超过512发送一次-->
  192. <!--
  193. <lossy value="true" />
  194. <evaluator type="log4net.Core.LevelEvaluator,log4net">
  195. <threshold value="WARN" />
  196. </evaluator>
  197. <layout type="log4net.Layout.PatternLayout,log4net">
  198. <conversionPattern value="
  199. %n【log4net的HostName】%property{log4net:HostName} ::
  200. %n【日志级别】%-5level
  201. %n【记录时间】%date
  202. %n【线程ID】[%thread]
  203. %n【出错文件】%F
  204. %n【出错行号】%L
  205. %n【出错的类】%logger 属性:%property{NDC}
  206. %n【错误描述】%message
  207. %newlineLogger: %logger%newlineThread: %thread%newlineDate: %date%newlineNDC:
  208. %n【错误详情】%newline%newline" />
  209. </layout>
  210. </appender>-->
  211. <!-- 使用SmtpPickupDir时的配置-->
  212. <!--<appender name="SmtpPickupDirAppender" type="log4net.Appender.SmtpPickupDirAppender">
  213. <to value="to@domain.com" />
  214. <from value="from@domain.com" />
  215. <subject value="test logging message" />
  216. <pickupDir value="C:\SmtpPickup" />
  217. <bufferSize value="512" />
  218. <lossy value="true" />
  219. <evaluator type="log4net.Core.LevelEvaluator">
  220. <threshold value="WARN"/>
  221. </evaluator>
  222. <layout type="log4net.Layout.PatternLayout">
  223. <conversionPattern value="%n==========
  224. %n【日志级别】%-5level
  225. %n【记录时间】%date
  226. %n【线程ID】[%thread]
  227. %n【出错文件】%F
  228. %n【出错行号】%L
  229. %n【出错的类】%logger 属性:[%property{NDC}]
  230. %n【错误描述】%message
  231. %n【错误详情】%newline" />
  232. </layout>
  233. </appender>-->