LogImpl.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. #region Apache License
  2. //
  3. // Licensed to the Apache Software Foundation (ASF) under one or more
  4. // contributor license agreements. See the NOTICE file distributed with
  5. // this work for additional information regarding copyright ownership.
  6. // The ASF licenses this file to you under the Apache License, Version 2.0
  7. // (the "License"); you may not use this file except in compliance with
  8. // the License. You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. //
  18. #endregion
  19. using System;
  20. using System.Globalization;
  21. using log4net.Repository;
  22. using log4net.Util;
  23. namespace log4net.Core
  24. {
  25. /// <summary>
  26. /// Implementation of <see cref="ILog"/> wrapper interface.
  27. /// </summary>
  28. /// <remarks>
  29. /// <para>
  30. /// This implementation of the <see cref="ILog"/> interface
  31. /// forwards to the <see cref="ILogger"/> held by the base class.
  32. /// </para>
  33. /// <para>
  34. /// This logger has methods to allow the caller to log at the following
  35. /// levels:
  36. /// </para>
  37. /// <list type="definition">
  38. /// <item>
  39. /// <term>DEBUG</term>
  40. /// <description>
  41. /// The <see cref="M:Debug(object)"/> and <see cref="M:DebugFormat(string, object[])"/> methods log messages
  42. /// at the <c>DEBUG</c> level. That is the level with that name defined in the
  43. /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
  44. /// for this level is <see cref="Level.Debug"/>. The <see cref="IsDebugEnabled"/>
  45. /// property tests if this level is enabled for logging.
  46. /// </description>
  47. /// </item>
  48. /// <item>
  49. /// <term>INFO</term>
  50. /// <description>
  51. /// The <see cref="M:Info(object)"/> and <see cref="M:InfoFormat(string, object[])"/> methods log messages
  52. /// at the <c>INFO</c> level. That is the level with that name defined in the
  53. /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
  54. /// for this level is <see cref="Level.Info"/>. The <see cref="IsInfoEnabled"/>
  55. /// property tests if this level is enabled for logging.
  56. /// </description>
  57. /// </item>
  58. /// <item>
  59. /// <term>WARN</term>
  60. /// <description>
  61. /// The <see cref="M:Warn(object)"/> and <see cref="M:WarnFormat(string, object[])"/> methods log messages
  62. /// at the <c>WARN</c> level. That is the level with that name defined in the
  63. /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
  64. /// for this level is <see cref="Level.Warn"/>. The <see cref="IsWarnEnabled"/>
  65. /// property tests if this level is enabled for logging.
  66. /// </description>
  67. /// </item>
  68. /// <item>
  69. /// <term>ERROR</term>
  70. /// <description>
  71. /// The <see cref="M:Error(object)"/> and <see cref="M:ErrorFormat(string, object[])"/> methods log messages
  72. /// at the <c>ERROR</c> level. That is the level with that name defined in the
  73. /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
  74. /// for this level is <see cref="Level.Error"/>. The <see cref="IsErrorEnabled"/>
  75. /// property tests if this level is enabled for logging.
  76. /// </description>
  77. /// </item>
  78. /// <item>
  79. /// <term>FATAL</term>
  80. /// <description>
  81. /// The <see cref="M:Fatal(object)"/> and <see cref="M:FatalFormat(string, object[])"/> methods log messages
  82. /// at the <c>FATAL</c> level. That is the level with that name defined in the
  83. /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
  84. /// for this level is <see cref="Level.Fatal"/>. The <see cref="IsFatalEnabled"/>
  85. /// property tests if this level is enabled for logging.
  86. /// </description>
  87. /// </item>
  88. /// </list>
  89. /// <para>
  90. /// The values for these levels and their semantic meanings can be changed by
  91. /// configuring the <see cref="ILoggerRepository.LevelMap"/> for the repository.
  92. /// </para>
  93. /// </remarks>
  94. /// <author>Nicko Cadell</author>
  95. /// <author>Gert Driesen</author>
  96. public class LogImpl : LoggerWrapperImpl, ILog
  97. {
  98. #region Public Instance Constructors
  99. /// <summary>
  100. /// Construct a new wrapper for the specified logger.
  101. /// </summary>
  102. /// <param name="logger">The logger to wrap.</param>
  103. /// <remarks>
  104. /// <para>
  105. /// Construct a new wrapper for the specified logger.
  106. /// </para>
  107. /// </remarks>
  108. public LogImpl(ILogger logger) : base(logger)
  109. {
  110. // Listen for changes to the repository
  111. logger.Repository.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(LoggerRepositoryConfigurationChanged);
  112. // load the current levels
  113. ReloadLevels(logger.Repository);
  114. }
  115. #endregion Public Instance Constructors
  116. /// <summary>
  117. /// Virtual method called when the configuration of the repository changes
  118. /// </summary>
  119. /// <param name="repository">the repository holding the levels</param>
  120. /// <remarks>
  121. /// <para>
  122. /// Virtual method called when the configuration of the repository changes
  123. /// </para>
  124. /// </remarks>
  125. protected virtual void ReloadLevels(ILoggerRepository repository)
  126. {
  127. LevelMap levelMap = repository.LevelMap;
  128. m_levelDebug = levelMap.LookupWithDefault(Level.Debug);
  129. m_levelInfo = levelMap.LookupWithDefault(Level.Info);
  130. m_levelWarn = levelMap.LookupWithDefault(Level.Warn);
  131. m_levelError = levelMap.LookupWithDefault(Level.Error);
  132. m_levelFatal = levelMap.LookupWithDefault(Level.Fatal);
  133. }
  134. #region Implementation of ILog
  135. /// <summary>
  136. /// Logs a message object with the <c>DEBUG</c> level.
  137. /// </summary>
  138. /// <param name="message">The message object to log.</param>
  139. /// <remarks>
  140. /// <para>
  141. /// This method first checks if this logger is <c>DEBUG</c>
  142. /// enabled by comparing the level of this logger with the
  143. /// <c>DEBUG</c> level. If this logger is
  144. /// <c>DEBUG</c> enabled, then it converts the message object
  145. /// (passed as parameter) to a string by invoking the appropriate
  146. /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
  147. /// proceeds to call all the registered appenders in this logger
  148. /// and also higher in the hierarchy depending on the value of the
  149. /// additivity flag.
  150. /// </para>
  151. /// <para>
  152. /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
  153. /// to this method will print the name of the <see cref="Exception"/>
  154. /// but no stack trace. To print a stack trace use the
  155. /// <see cref="M:Debug(object,Exception)"/> form instead.
  156. /// </para>
  157. /// </remarks>
  158. virtual public void Debug(object message)
  159. {
  160. Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
  161. }
  162. /// <summary>
  163. /// Logs a message object with the <c>DEBUG</c> level
  164. /// </summary>
  165. /// <param name="message">The message object to log.</param>
  166. /// <param name="exception">The exception to log, including its stack trace.</param>
  167. /// <remarks>
  168. /// <para>
  169. /// Logs a message object with the <c>DEBUG</c> level including
  170. /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/> passed
  171. /// as a parameter.
  172. /// </para>
  173. /// <para>
  174. /// See the <see cref="M:Debug(object)"/> form for more detailed information.
  175. /// </para>
  176. /// </remarks>
  177. /// <seealso cref="M:Debug(object)"/>
  178. virtual public void Debug(object message, Exception exception)
  179. {
  180. Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
  181. }
  182. /// <summary>
  183. /// Logs a formatted message string with the <c>DEBUG</c> level.
  184. /// </summary>
  185. /// <param name="format">A String containing zero or more format items</param>
  186. /// <param name="args">An Object array containing zero or more objects to format</param>
  187. /// <remarks>
  188. /// <para>
  189. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  190. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  191. /// of the formatting.
  192. /// </para>
  193. /// <para>
  194. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  195. /// format provider. To specify a localized provider use the
  196. /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
  197. /// </para>
  198. /// <para>
  199. /// This method does not take an <see cref="Exception"/> object to include in the
  200. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
  201. /// methods instead.
  202. /// </para>
  203. /// </remarks>
  204. virtual public void DebugFormat(string format, params object[] args)
  205. {
  206. if (IsDebugEnabled)
  207. {
  208. Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
  209. }
  210. }
  211. /// <summary>
  212. /// Logs a formatted message string with the <c>DEBUG</c> level.
  213. /// </summary>
  214. /// <param name="format">A String containing zero or more format items</param>
  215. /// <param name="arg0">An Object to format</param>
  216. /// <remarks>
  217. /// <para>
  218. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  219. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  220. /// of the formatting.
  221. /// </para>
  222. /// <para>
  223. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  224. /// format provider. To specify a localized provider use the
  225. /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
  226. /// </para>
  227. /// <para>
  228. /// This method does not take an <see cref="Exception"/> object to include in the
  229. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
  230. /// methods instead.
  231. /// </para>
  232. /// </remarks>
  233. virtual public void DebugFormat(string format, object arg0)
  234. {
  235. if (IsDebugEnabled)
  236. {
  237. Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
  238. }
  239. }
  240. /// <summary>
  241. /// Logs a formatted message string with the <c>DEBUG</c> level.
  242. /// </summary>
  243. /// <param name="format">A String containing zero or more format items</param>
  244. /// <param name="arg0">An Object to format</param>
  245. /// <param name="arg1">An Object to format</param>
  246. /// <remarks>
  247. /// <para>
  248. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  249. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  250. /// of the formatting.
  251. /// </para>
  252. /// <para>
  253. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  254. /// format provider. To specify a localized provider use the
  255. /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
  256. /// </para>
  257. /// <para>
  258. /// This method does not take an <see cref="Exception"/> object to include in the
  259. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
  260. /// methods instead.
  261. /// </para>
  262. /// </remarks>
  263. virtual public void DebugFormat(string format, object arg0, object arg1)
  264. {
  265. if (IsDebugEnabled)
  266. {
  267. Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
  268. }
  269. }
  270. /// <summary>
  271. /// Logs a formatted message string with the <c>DEBUG</c> level.
  272. /// </summary>
  273. /// <param name="format">A String containing zero or more format items</param>
  274. /// <param name="arg0">An Object to format</param>
  275. /// <param name="arg1">An Object to format</param>
  276. /// <param name="arg2">An Object to format</param>
  277. /// <remarks>
  278. /// <para>
  279. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  280. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  281. /// of the formatting.
  282. /// </para>
  283. /// <para>
  284. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  285. /// format provider. To specify a localized provider use the
  286. /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
  287. /// </para>
  288. /// <para>
  289. /// This method does not take an <see cref="Exception"/> object to include in the
  290. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
  291. /// methods instead.
  292. /// </para>
  293. /// </remarks>
  294. virtual public void DebugFormat(string format, object arg0, object arg1, object arg2)
  295. {
  296. if (IsDebugEnabled)
  297. {
  298. Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
  299. }
  300. }
  301. /// <summary>
  302. /// Logs a formatted message string with the <c>DEBUG</c> level.
  303. /// </summary>
  304. /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
  305. /// <param name="format">A String containing zero or more format items</param>
  306. /// <param name="args">An Object array containing zero or more objects to format</param>
  307. /// <remarks>
  308. /// <para>
  309. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  310. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  311. /// of the formatting.
  312. /// </para>
  313. /// <para>
  314. /// This method does not take an <see cref="Exception"/> object to include in the
  315. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
  316. /// methods instead.
  317. /// </para>
  318. /// </remarks>
  319. virtual public void DebugFormat(IFormatProvider provider, string format, params object[] args)
  320. {
  321. if (IsDebugEnabled)
  322. {
  323. Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
  324. }
  325. }
  326. /// <summary>
  327. /// Logs a message object with the <c>INFO</c> level.
  328. /// </summary>
  329. /// <param name="message">The message object to log.</param>
  330. /// <remarks>
  331. /// <para>
  332. /// This method first checks if this logger is <c>INFO</c>
  333. /// enabled by comparing the level of this logger with the
  334. /// <c>INFO</c> level. If this logger is
  335. /// <c>INFO</c> enabled, then it converts the message object
  336. /// (passed as parameter) to a string by invoking the appropriate
  337. /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
  338. /// proceeds to call all the registered appenders in this logger
  339. /// and also higher in the hierarchy depending on the value of
  340. /// the additivity flag.
  341. /// </para>
  342. /// <para>
  343. /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
  344. /// to this method will print the name of the <see cref="Exception"/>
  345. /// but no stack trace. To print a stack trace use the
  346. /// <see cref="M:Info(object,Exception)"/> form instead.
  347. /// </para>
  348. /// </remarks>
  349. virtual public void Info(object message)
  350. {
  351. Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
  352. }
  353. /// <summary>
  354. /// Logs a message object with the <c>INFO</c> level.
  355. /// </summary>
  356. /// <param name="message">The message object to log.</param>
  357. /// <param name="exception">The exception to log, including its stack trace.</param>
  358. /// <remarks>
  359. /// <para>
  360. /// Logs a message object with the <c>INFO</c> level including
  361. /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
  362. /// passed as a parameter.
  363. /// </para>
  364. /// <para>
  365. /// See the <see cref="M:Info(object)"/> form for more detailed information.
  366. /// </para>
  367. /// </remarks>
  368. /// <seealso cref="M:Info(object)"/>
  369. virtual public void Info(object message, Exception exception)
  370. {
  371. Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
  372. }
  373. /// <summary>
  374. /// Logs a formatted message string with the <c>INFO</c> level.
  375. /// </summary>
  376. /// <param name="format">A String containing zero or more format items</param>
  377. /// <param name="args">An Object array containing zero or more objects to format</param>
  378. /// <remarks>
  379. /// <para>
  380. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  381. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  382. /// of the formatting.
  383. /// </para>
  384. /// <para>
  385. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  386. /// format provider. To specify a localized provider use the
  387. /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
  388. /// </para>
  389. /// <para>
  390. /// This method does not take an <see cref="Exception"/> object to include in the
  391. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
  392. /// methods instead.
  393. /// </para>
  394. /// </remarks>
  395. virtual public void InfoFormat(string format, params object[] args)
  396. {
  397. if (IsInfoEnabled)
  398. {
  399. Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
  400. }
  401. }
  402. /// <summary>
  403. /// Logs a formatted message string with the <c>INFO</c> level.
  404. /// </summary>
  405. /// <param name="format">A String containing zero or more format items</param>
  406. /// <param name="arg0">An Object to format</param>
  407. /// <remarks>
  408. /// <para>
  409. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  410. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  411. /// of the formatting.
  412. /// </para>
  413. /// <para>
  414. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  415. /// format provider. To specify a localized provider use the
  416. /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
  417. /// </para>
  418. /// <para>
  419. /// This method does not take an <see cref="Exception"/> object to include in the
  420. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
  421. /// methods instead.
  422. /// </para>
  423. /// </remarks>
  424. virtual public void InfoFormat(string format, object arg0)
  425. {
  426. if (IsInfoEnabled)
  427. {
  428. Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
  429. }
  430. }
  431. /// <summary>
  432. /// Logs a formatted message string with the <c>INFO</c> level.
  433. /// </summary>
  434. /// <param name="format">A String containing zero or more format items</param>
  435. /// <param name="arg0">An Object to format</param>
  436. /// <param name="arg1">An Object to format</param>
  437. /// <remarks>
  438. /// <para>
  439. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  440. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  441. /// of the formatting.
  442. /// </para>
  443. /// <para>
  444. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  445. /// format provider. To specify a localized provider use the
  446. /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
  447. /// </para>
  448. /// <para>
  449. /// This method does not take an <see cref="Exception"/> object to include in the
  450. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
  451. /// methods instead.
  452. /// </para>
  453. /// </remarks>
  454. virtual public void InfoFormat(string format, object arg0, object arg1)
  455. {
  456. if (IsInfoEnabled)
  457. {
  458. Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
  459. }
  460. }
  461. /// <summary>
  462. /// Logs a formatted message string with the <c>INFO</c> level.
  463. /// </summary>
  464. /// <param name="format">A String containing zero or more format items</param>
  465. /// <param name="arg0">An Object to format</param>
  466. /// <param name="arg1">An Object to format</param>
  467. /// <param name="arg2">An Object to format</param>
  468. /// <remarks>
  469. /// <para>
  470. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  471. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  472. /// of the formatting.
  473. /// </para>
  474. /// <para>
  475. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  476. /// format provider. To specify a localized provider use the
  477. /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
  478. /// </para>
  479. /// <para>
  480. /// This method does not take an <see cref="Exception"/> object to include in the
  481. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
  482. /// methods instead.
  483. /// </para>
  484. /// </remarks>
  485. virtual public void InfoFormat(string format, object arg0, object arg1, object arg2)
  486. {
  487. if (IsInfoEnabled)
  488. {
  489. Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
  490. }
  491. }
  492. /// <summary>
  493. /// Logs a formatted message string with the <c>INFO</c> level.
  494. /// </summary>
  495. /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
  496. /// <param name="format">A String containing zero or more format items</param>
  497. /// <param name="args">An Object array containing zero or more objects to format</param>
  498. /// <remarks>
  499. /// <para>
  500. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  501. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  502. /// of the formatting.
  503. /// </para>
  504. /// <para>
  505. /// This method does not take an <see cref="Exception"/> object to include in the
  506. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
  507. /// methods instead.
  508. /// </para>
  509. /// </remarks>
  510. virtual public void InfoFormat(IFormatProvider provider, string format, params object[] args)
  511. {
  512. if (IsInfoEnabled)
  513. {
  514. Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
  515. }
  516. }
  517. /// <summary>
  518. /// Logs a message object with the <c>WARN</c> level.
  519. /// </summary>
  520. /// <param name="message">the message object to log</param>
  521. /// <remarks>
  522. /// <para>
  523. /// This method first checks if this logger is <c>WARN</c>
  524. /// enabled by comparing the level of this logger with the
  525. /// <c>WARN</c> level. If this logger is
  526. /// <c>WARN</c> enabled, then it converts the message object
  527. /// (passed as parameter) to a string by invoking the appropriate
  528. /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
  529. /// proceeds to call all the registered appenders in this logger and
  530. /// also higher in the hierarchy depending on the value of the
  531. /// additivity flag.
  532. /// </para>
  533. /// <para>
  534. /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
  535. /// method will print the name of the <see cref="Exception"/> but no
  536. /// stack trace. To print a stack trace use the
  537. /// <see cref="M:Warn(object,Exception)"/> form instead.
  538. /// </para>
  539. /// </remarks>
  540. virtual public void Warn(object message)
  541. {
  542. Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
  543. }
  544. /// <summary>
  545. /// Logs a message object with the <c>WARN</c> level
  546. /// </summary>
  547. /// <param name="message">The message object to log.</param>
  548. /// <param name="exception">The exception to log, including its stack trace.</param>
  549. /// <remarks>
  550. /// <para>
  551. /// Logs a message object with the <c>WARN</c> level including
  552. /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
  553. /// passed as a parameter.
  554. /// </para>
  555. /// <para>
  556. /// See the <see cref="M:Warn(object)"/> form for more detailed information.
  557. /// </para>
  558. /// </remarks>
  559. /// <seealso cref="M:Warn(object)"/>
  560. virtual public void Warn(object message, Exception exception)
  561. {
  562. Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
  563. }
  564. /// <summary>
  565. /// Logs a formatted message string with the <c>WARN</c> level.
  566. /// </summary>
  567. /// <param name="format">A String containing zero or more format items</param>
  568. /// <param name="args">An Object array containing zero or more objects to format</param>
  569. /// <remarks>
  570. /// <para>
  571. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  572. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  573. /// of the formatting.
  574. /// </para>
  575. /// <para>
  576. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  577. /// format provider. To specify a localized provider use the
  578. /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
  579. /// </para>
  580. /// <para>
  581. /// This method does not take an <see cref="Exception"/> object to include in the
  582. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
  583. /// methods instead.
  584. /// </para>
  585. /// </remarks>
  586. virtual public void WarnFormat(string format, params object[] args)
  587. {
  588. if (IsWarnEnabled)
  589. {
  590. Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
  591. }
  592. }
  593. /// <summary>
  594. /// Logs a formatted message string with the <c>WARN</c> level.
  595. /// </summary>
  596. /// <param name="format">A String containing zero or more format items</param>
  597. /// <param name="arg0">An Object to format</param>
  598. /// <remarks>
  599. /// <para>
  600. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  601. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  602. /// of the formatting.
  603. /// </para>
  604. /// <para>
  605. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  606. /// format provider. To specify a localized provider use the
  607. /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
  608. /// </para>
  609. /// <para>
  610. /// This method does not take an <see cref="Exception"/> object to include in the
  611. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
  612. /// methods instead.
  613. /// </para>
  614. /// </remarks>
  615. virtual public void WarnFormat(string format, object arg0)
  616. {
  617. if (IsWarnEnabled)
  618. {
  619. Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
  620. }
  621. }
  622. /// <summary>
  623. /// Logs a formatted message string with the <c>WARN</c> level.
  624. /// </summary>
  625. /// <param name="format">A String containing zero or more format items</param>
  626. /// <param name="arg0">An Object to format</param>
  627. /// <param name="arg1">An Object to format</param>
  628. /// <remarks>
  629. /// <para>
  630. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  631. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  632. /// of the formatting.
  633. /// </para>
  634. /// <para>
  635. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  636. /// format provider. To specify a localized provider use the
  637. /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
  638. /// </para>
  639. /// <para>
  640. /// This method does not take an <see cref="Exception"/> object to include in the
  641. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
  642. /// methods instead.
  643. /// </para>
  644. /// </remarks>
  645. virtual public void WarnFormat(string format, object arg0, object arg1)
  646. {
  647. if (IsWarnEnabled)
  648. {
  649. Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
  650. }
  651. }
  652. /// <summary>
  653. /// Logs a formatted message string with the <c>WARN</c> level.
  654. /// </summary>
  655. /// <param name="format">A String containing zero or more format items</param>
  656. /// <param name="arg0">An Object to format</param>
  657. /// <param name="arg1">An Object to format</param>
  658. /// <param name="arg2">An Object to format</param>
  659. /// <remarks>
  660. /// <para>
  661. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  662. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  663. /// of the formatting.
  664. /// </para>
  665. /// <para>
  666. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  667. /// format provider. To specify a localized provider use the
  668. /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
  669. /// </para>
  670. /// <para>
  671. /// This method does not take an <see cref="Exception"/> object to include in the
  672. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
  673. /// methods instead.
  674. /// </para>
  675. /// </remarks>
  676. virtual public void WarnFormat(string format, object arg0, object arg1, object arg2)
  677. {
  678. if (IsWarnEnabled)
  679. {
  680. Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
  681. }
  682. }
  683. /// <summary>
  684. /// Logs a formatted message string with the <c>WARN</c> level.
  685. /// </summary>
  686. /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
  687. /// <param name="format">A String containing zero or more format items</param>
  688. /// <param name="args">An Object array containing zero or more objects to format</param>
  689. /// <remarks>
  690. /// <para>
  691. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  692. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  693. /// of the formatting.
  694. /// </para>
  695. /// <para>
  696. /// This method does not take an <see cref="Exception"/> object to include in the
  697. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
  698. /// methods instead.
  699. /// </para>
  700. /// </remarks>
  701. virtual public void WarnFormat(IFormatProvider provider, string format, params object[] args)
  702. {
  703. if (IsWarnEnabled)
  704. {
  705. Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
  706. }
  707. }
  708. /// <summary>
  709. /// Logs a message object with the <c>ERROR</c> level.
  710. /// </summary>
  711. /// <param name="message">The message object to log.</param>
  712. /// <remarks>
  713. /// <para>
  714. /// This method first checks if this logger is <c>ERROR</c>
  715. /// enabled by comparing the level of this logger with the
  716. /// <c>ERROR</c> level. If this logger is
  717. /// <c>ERROR</c> enabled, then it converts the message object
  718. /// (passed as parameter) to a string by invoking the appropriate
  719. /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
  720. /// proceeds to call all the registered appenders in this logger and
  721. /// also higher in the hierarchy depending on the value of the
  722. /// additivity flag.
  723. /// </para>
  724. /// <para>
  725. /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
  726. /// method will print the name of the <see cref="Exception"/> but no
  727. /// stack trace. To print a stack trace use the
  728. /// <see cref="M:Error(object,Exception)"/> form instead.
  729. /// </para>
  730. /// </remarks>
  731. virtual public void Error(object message)
  732. {
  733. Logger.Log(ThisDeclaringType, m_levelError, message, null);
  734. }
  735. /// <summary>
  736. /// Logs a message object with the <c>ERROR</c> level
  737. /// </summary>
  738. /// <param name="message">The message object to log.</param>
  739. /// <param name="exception">The exception to log, including its stack trace.</param>
  740. /// <remarks>
  741. /// <para>
  742. /// Logs a message object with the <c>ERROR</c> level including
  743. /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
  744. /// passed as a parameter.
  745. /// </para>
  746. /// <para>
  747. /// See the <see cref="M:Error(object)"/> form for more detailed information.
  748. /// </para>
  749. /// </remarks>
  750. /// <seealso cref="M:Error(object)"/>
  751. virtual public void Error(object message, Exception exception)
  752. {
  753. Logger.Log(ThisDeclaringType, m_levelError, message, exception);
  754. }
  755. /// <summary>
  756. /// Logs a formatted message string with the <c>ERROR</c> level.
  757. /// </summary>
  758. /// <param name="format">A String containing zero or more format items</param>
  759. /// <param name="args">An Object array containing zero or more objects to format</param>
  760. /// <remarks>
  761. /// <para>
  762. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  763. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  764. /// of the formatting.
  765. /// </para>
  766. /// <para>
  767. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  768. /// format provider. To specify a localized provider use the
  769. /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
  770. /// </para>
  771. /// <para>
  772. /// This method does not take an <see cref="Exception"/> object to include in the
  773. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
  774. /// methods instead.
  775. /// </para>
  776. /// </remarks>
  777. virtual public void ErrorFormat(string format, params object[] args)
  778. {
  779. if (IsErrorEnabled)
  780. {
  781. Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
  782. }
  783. }
  784. /// <summary>
  785. /// Logs a formatted message string with the <c>ERROR</c> level.
  786. /// </summary>
  787. /// <param name="format">A String containing zero or more format items</param>
  788. /// <param name="arg0">An Object to format</param>
  789. /// <remarks>
  790. /// <para>
  791. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  792. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  793. /// of the formatting.
  794. /// </para>
  795. /// <para>
  796. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  797. /// format provider. To specify a localized provider use the
  798. /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
  799. /// </para>
  800. /// <para>
  801. /// This method does not take an <see cref="Exception"/> object to include in the
  802. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
  803. /// methods instead.
  804. /// </para>
  805. /// </remarks>
  806. virtual public void ErrorFormat(string format, object arg0)
  807. {
  808. if (IsErrorEnabled)
  809. {
  810. Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
  811. }
  812. }
  813. /// <summary>
  814. /// Logs a formatted message string with the <c>ERROR</c> level.
  815. /// </summary>
  816. /// <param name="format">A String containing zero or more format items</param>
  817. /// <param name="arg0">An Object to format</param>
  818. /// <param name="arg1">An Object to format</param>
  819. /// <remarks>
  820. /// <para>
  821. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  822. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  823. /// of the formatting.
  824. /// </para>
  825. /// <para>
  826. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  827. /// format provider. To specify a localized provider use the
  828. /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
  829. /// </para>
  830. /// <para>
  831. /// This method does not take an <see cref="Exception"/> object to include in the
  832. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
  833. /// methods instead.
  834. /// </para>
  835. /// </remarks>
  836. virtual public void ErrorFormat(string format, object arg0, object arg1)
  837. {
  838. if (IsErrorEnabled)
  839. {
  840. Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
  841. }
  842. }
  843. /// <summary>
  844. /// Logs a formatted message string with the <c>ERROR</c> level.
  845. /// </summary>
  846. /// <param name="format">A String containing zero or more format items</param>
  847. /// <param name="arg0">An Object to format</param>
  848. /// <param name="arg1">An Object to format</param>
  849. /// <param name="arg2">An Object to format</param>
  850. /// <remarks>
  851. /// <para>
  852. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  853. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  854. /// of the formatting.
  855. /// </para>
  856. /// <para>
  857. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  858. /// format provider. To specify a localized provider use the
  859. /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
  860. /// </para>
  861. /// <para>
  862. /// This method does not take an <see cref="Exception"/> object to include in the
  863. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
  864. /// methods instead.
  865. /// </para>
  866. /// </remarks>
  867. virtual public void ErrorFormat(string format, object arg0, object arg1, object arg2)
  868. {
  869. if (IsErrorEnabled)
  870. {
  871. Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
  872. }
  873. }
  874. /// <summary>
  875. /// Logs a formatted message string with the <c>ERROR</c> level.
  876. /// </summary>
  877. /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
  878. /// <param name="format">A String containing zero or more format items</param>
  879. /// <param name="args">An Object array containing zero or more objects to format</param>
  880. /// <remarks>
  881. /// <para>
  882. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  883. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  884. /// of the formatting.
  885. /// </para>
  886. /// <para>
  887. /// This method does not take an <see cref="Exception"/> object to include in the
  888. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
  889. /// methods instead.
  890. /// </para>
  891. /// </remarks>
  892. virtual public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
  893. {
  894. if (IsErrorEnabled)
  895. {
  896. Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
  897. }
  898. }
  899. /// <summary>
  900. /// Logs a message object with the <c>FATAL</c> level.
  901. /// </summary>
  902. /// <param name="message">The message object to log.</param>
  903. /// <remarks>
  904. /// <para>
  905. /// This method first checks if this logger is <c>FATAL</c>
  906. /// enabled by comparing the level of this logger with the
  907. /// <c>FATAL</c> level. If this logger is
  908. /// <c>FATAL</c> enabled, then it converts the message object
  909. /// (passed as parameter) to a string by invoking the appropriate
  910. /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
  911. /// proceeds to call all the registered appenders in this logger and
  912. /// also higher in the hierarchy depending on the value of the
  913. /// additivity flag.
  914. /// </para>
  915. /// <para>
  916. /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
  917. /// method will print the name of the <see cref="Exception"/> but no
  918. /// stack trace. To print a stack trace use the
  919. /// <see cref="M:Fatal(object,Exception)"/> form instead.
  920. /// </para>
  921. /// </remarks>
  922. virtual public void Fatal(object message)
  923. {
  924. Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
  925. }
  926. /// <summary>
  927. /// Logs a message object with the <c>FATAL</c> level
  928. /// </summary>
  929. /// <param name="message">The message object to log.</param>
  930. /// <param name="exception">The exception to log, including its stack trace.</param>
  931. /// <remarks>
  932. /// <para>
  933. /// Logs a message object with the <c>FATAL</c> level including
  934. /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
  935. /// passed as a parameter.
  936. /// </para>
  937. /// <para>
  938. /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
  939. /// </para>
  940. /// </remarks>
  941. /// <seealso cref="M:Fatal(object)"/>
  942. virtual public void Fatal(object message, Exception exception)
  943. {
  944. Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
  945. }
  946. /// <summary>
  947. /// Logs a formatted message string with the <c>FATAL</c> level.
  948. /// </summary>
  949. /// <param name="format">A String containing zero or more format items</param>
  950. /// <param name="args">An Object array containing zero or more objects to format</param>
  951. /// <remarks>
  952. /// <para>
  953. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  954. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  955. /// of the formatting.
  956. /// </para>
  957. /// <para>
  958. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  959. /// format provider. To specify a localized provider use the
  960. /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
  961. /// </para>
  962. /// <para>
  963. /// This method does not take an <see cref="Exception"/> object to include in the
  964. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
  965. /// methods instead.
  966. /// </para>
  967. /// </remarks>
  968. virtual public void FatalFormat(string format, params object[] args)
  969. {
  970. if (IsFatalEnabled)
  971. {
  972. Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
  973. }
  974. }
  975. /// <summary>
  976. /// Logs a formatted message string with the <c>FATAL</c> level.
  977. /// </summary>
  978. /// <param name="format">A String containing zero or more format items</param>
  979. /// <param name="arg0">An Object to format</param>
  980. /// <remarks>
  981. /// <para>
  982. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  983. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  984. /// of the formatting.
  985. /// </para>
  986. /// <para>
  987. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  988. /// format provider. To specify a localized provider use the
  989. /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
  990. /// </para>
  991. /// <para>
  992. /// This method does not take an <see cref="Exception"/> object to include in the
  993. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
  994. /// methods instead.
  995. /// </para>
  996. /// </remarks>
  997. virtual public void FatalFormat(string format, object arg0)
  998. {
  999. if (IsFatalEnabled)
  1000. {
  1001. Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
  1002. }
  1003. }
  1004. /// <summary>
  1005. /// Logs a formatted message string with the <c>FATAL</c> level.
  1006. /// </summary>
  1007. /// <param name="format">A String containing zero or more format items</param>
  1008. /// <param name="arg0">An Object to format</param>
  1009. /// <param name="arg1">An Object to format</param>
  1010. /// <remarks>
  1011. /// <para>
  1012. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  1013. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  1014. /// of the formatting.
  1015. /// </para>
  1016. /// <para>
  1017. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  1018. /// format provider. To specify a localized provider use the
  1019. /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
  1020. /// </para>
  1021. /// <para>
  1022. /// This method does not take an <see cref="Exception"/> object to include in the
  1023. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
  1024. /// methods instead.
  1025. /// </para>
  1026. /// </remarks>
  1027. virtual public void FatalFormat(string format, object arg0, object arg1)
  1028. {
  1029. if (IsFatalEnabled)
  1030. {
  1031. Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
  1032. }
  1033. }
  1034. /// <summary>
  1035. /// Logs a formatted message string with the <c>FATAL</c> level.
  1036. /// </summary>
  1037. /// <param name="format">A String containing zero or more format items</param>
  1038. /// <param name="arg0">An Object to format</param>
  1039. /// <param name="arg1">An Object to format</param>
  1040. /// <param name="arg2">An Object to format</param>
  1041. /// <remarks>
  1042. /// <para>
  1043. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  1044. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  1045. /// of the formatting.
  1046. /// </para>
  1047. /// <para>
  1048. /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
  1049. /// format provider. To specify a localized provider use the
  1050. /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
  1051. /// </para>
  1052. /// <para>
  1053. /// This method does not take an <see cref="Exception"/> object to include in the
  1054. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
  1055. /// methods instead.
  1056. /// </para>
  1057. /// </remarks>
  1058. virtual public void FatalFormat(string format, object arg0, object arg1, object arg2)
  1059. {
  1060. if (IsFatalEnabled)
  1061. {
  1062. Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
  1063. }
  1064. }
  1065. /// <summary>
  1066. /// Logs a formatted message string with the <c>FATAL</c> level.
  1067. /// </summary>
  1068. /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
  1069. /// <param name="format">A String containing zero or more format items</param>
  1070. /// <param name="args">An Object array containing zero or more objects to format</param>
  1071. /// <remarks>
  1072. /// <para>
  1073. /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
  1074. /// <c>String.Format</c> for details of the syntax of the format string and the behavior
  1075. /// of the formatting.
  1076. /// </para>
  1077. /// <para>
  1078. /// This method does not take an <see cref="Exception"/> object to include in the
  1079. /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
  1080. /// methods instead.
  1081. /// </para>
  1082. /// </remarks>
  1083. virtual public void FatalFormat(IFormatProvider provider, string format, params object[] args)
  1084. {
  1085. if (IsFatalEnabled)
  1086. {
  1087. Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
  1088. }
  1089. }
  1090. /// <summary>
  1091. /// Checks if this logger is enabled for the <c>DEBUG</c>
  1092. /// level.
  1093. /// </summary>
  1094. /// <value>
  1095. /// <c>true</c> if this logger is enabled for <c>DEBUG</c> events,
  1096. /// <c>false</c> otherwise.
  1097. /// </value>
  1098. /// <remarks>
  1099. /// <para>
  1100. /// This function is intended to lessen the computational cost of
  1101. /// disabled log debug statements.
  1102. /// </para>
  1103. /// <para>
  1104. /// For some <c>log</c> Logger object, when you write:
  1105. /// </para>
  1106. /// <code lang="C#">
  1107. /// log.Debug("This is entry number: " + i );
  1108. /// </code>
  1109. /// <para>
  1110. /// You incur the cost constructing the message, concatenation in
  1111. /// this case, regardless of whether the message is logged or not.
  1112. /// </para>
  1113. /// <para>
  1114. /// If you are worried about speed, then you should write:
  1115. /// </para>
  1116. /// <code lang="C#">
  1117. /// if (log.IsDebugEnabled())
  1118. /// {
  1119. /// log.Debug("This is entry number: " + i );
  1120. /// }
  1121. /// </code>
  1122. /// <para>
  1123. /// This way you will not incur the cost of parameter
  1124. /// construction if debugging is disabled for <c>log</c>. On
  1125. /// the other hand, if the <c>log</c> is debug enabled, you
  1126. /// will incur the cost of evaluating whether the logger is debug
  1127. /// enabled twice. Once in <c>IsDebugEnabled</c> and once in
  1128. /// the <c>Debug</c>. This is an insignificant overhead
  1129. /// since evaluating a logger takes about 1% of the time it
  1130. /// takes to actually log.
  1131. /// </para>
  1132. /// </remarks>
  1133. virtual public bool IsDebugEnabled
  1134. {
  1135. get { return Logger.IsEnabledFor(m_levelDebug); }
  1136. }
  1137. /// <summary>
  1138. /// Checks if this logger is enabled for the <c>INFO</c> level.
  1139. /// </summary>
  1140. /// <value>
  1141. /// <c>true</c> if this logger is enabled for <c>INFO</c> events,
  1142. /// <c>false</c> otherwise.
  1143. /// </value>
  1144. /// <remarks>
  1145. /// <para>
  1146. /// See <see cref="IsDebugEnabled"/> for more information and examples
  1147. /// of using this method.
  1148. /// </para>
  1149. /// </remarks>
  1150. /// <seealso cref="LogImpl.IsDebugEnabled"/>
  1151. virtual public bool IsInfoEnabled
  1152. {
  1153. get { return Logger.IsEnabledFor(m_levelInfo); }
  1154. }
  1155. /// <summary>
  1156. /// Checks if this logger is enabled for the <c>WARN</c> level.
  1157. /// </summary>
  1158. /// <value>
  1159. /// <c>true</c> if this logger is enabled for <c>WARN</c> events,
  1160. /// <c>false</c> otherwise.
  1161. /// </value>
  1162. /// <remarks>
  1163. /// <para>
  1164. /// See <see cref="IsDebugEnabled"/> for more information and examples
  1165. /// of using this method.
  1166. /// </para>
  1167. /// </remarks>
  1168. /// <seealso cref="ILog.IsDebugEnabled"/>
  1169. virtual public bool IsWarnEnabled
  1170. {
  1171. get { return Logger.IsEnabledFor(m_levelWarn); }
  1172. }
  1173. /// <summary>
  1174. /// Checks if this logger is enabled for the <c>ERROR</c> level.
  1175. /// </summary>
  1176. /// <value>
  1177. /// <c>true</c> if this logger is enabled for <c>ERROR</c> events,
  1178. /// <c>false</c> otherwise.
  1179. /// </value>
  1180. /// <remarks>
  1181. /// <para>
  1182. /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
  1183. /// </para>
  1184. /// </remarks>
  1185. /// <seealso cref="ILog.IsDebugEnabled"/>
  1186. virtual public bool IsErrorEnabled
  1187. {
  1188. get { return Logger.IsEnabledFor(m_levelError); }
  1189. }
  1190. /// <summary>
  1191. /// Checks if this logger is enabled for the <c>FATAL</c> level.
  1192. /// </summary>
  1193. /// <value>
  1194. /// <c>true</c> if this logger is enabled for <c>FATAL</c> events,
  1195. /// <c>false</c> otherwise.
  1196. /// </value>
  1197. /// <remarks>
  1198. /// <para>
  1199. /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
  1200. /// </para>
  1201. /// </remarks>
  1202. /// <seealso cref="ILog.IsDebugEnabled"/>
  1203. virtual public bool IsFatalEnabled
  1204. {
  1205. get { return Logger.IsEnabledFor(m_levelFatal); }
  1206. }
  1207. #endregion Implementation of ILog
  1208. #region Private Methods
  1209. /// <summary>
  1210. /// Event handler for the <see cref="log4net.Repository.ILoggerRepository.ConfigurationChanged"/> event
  1211. /// </summary>
  1212. /// <param name="sender">the repository</param>
  1213. /// <param name="e">Empty</param>
  1214. private void LoggerRepositoryConfigurationChanged(object sender, EventArgs e)
  1215. {
  1216. ILoggerRepository repository = sender as ILoggerRepository;
  1217. if (repository != null)
  1218. {
  1219. ReloadLevels(repository);
  1220. }
  1221. }
  1222. #endregion
  1223. #region Private Static Instance Fields
  1224. /// <summary>
  1225. /// The fully qualified name of this declaring type not the type of any subclass.
  1226. /// </summary>
  1227. private readonly static Type ThisDeclaringType = typeof(LogImpl);
  1228. #endregion Private Static Instance Fields
  1229. #region Private Fields
  1230. private Level m_levelDebug;
  1231. private Level m_levelInfo;
  1232. private Level m_levelWarn;
  1233. private Level m_levelError;
  1234. private Level m_levelFatal;
  1235. #endregion
  1236. }
  1237. }