PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/SSATool.Common.Logging/Logger.cs

#
C# | 1040 lines | 196 code | 59 blank | 785 comment | 0 complexity | 672bd9d46d55efa61ad46f27bce37cc8 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. #region Header
  2. // ------------------------ Licence / Copyright ------------------------
  3. //
  4. // Simple Service Administration Tool for WinNT based systems.
  5. // Copyright © 2010 - Silvan Gehrig
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Lesser General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2.1 of the License, or (at your option) any later version.
  11. //
  12. // This library is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. // Lesser General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU Lesser General Public
  18. // License along with this library; if not, write to the Free Software
  19. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. //
  21. // Author:
  22. // Silvan Gehrig
  23. //
  24. // ---------------------------------------------------------------------
  25. #endregion
  26. #region Usings
  27. using System;
  28. using log4net;
  29. #endregion
  30. namespace SSATool.Common.Logging
  31. {
  32. /// <summary>
  33. /// Contains the global utilities for the logging purposes.
  34. /// </summary>
  35. /// <remarks>
  36. /// The implementation of the current class follows the borg
  37. /// "pattern".
  38. /// </remarks>
  39. /// <typeparam name="T">Specifies the logging category.</typeparam>
  40. public class Logger<T>
  41. {
  42. #region Declarations
  43. //--------------------------------------------------------------------
  44. // Declarations
  45. //--------------------------------------------------------------------
  46. private static readonly ILog Log = LogManager.GetLogger(typeof (T));
  47. #endregion
  48. #region Constructors / Destructor
  49. //--------------------------------------------------------------------
  50. // Constructors / Destructor
  51. //--------------------------------------------------------------------
  52. /// <summary>
  53. /// Do not create public instances of the typed logger class.
  54. /// </summary>
  55. protected Logger()
  56. {
  57. }
  58. #endregion
  59. #region Properties
  60. //--------------------------------------------------------------------
  61. // Properties
  62. //--------------------------------------------------------------------
  63. /// <summary>
  64. /// Nested Diagnostic Context (NDC) uses a stack per thread to identify different clients. It is the developer's responsibility to put
  65. /// in a unique value for each client. To constrain NDC into a certain block of code, the developer can use
  66. /// the "using" statement to make his task easier, because it automatically pops the respective value from the stack.
  67. /// </summary>
  68. /// <param name="putValue">Specifies the Nested Diagnostic Context (NDC) value to identify different clients.</param>
  69. public static IDisposable StartNdc(string putValue)
  70. {
  71. return NDC.Push(putValue);
  72. }
  73. /// <summary>
  74. /// Checks if this logger is enabled for the <see cref="F:log4net.Core.Level.Debug"/> level.
  75. /// </summary>
  76. /// <value>
  77. /// <c>true</c> if this logger is enabled for <see cref="F:log4net.Core.Level.Debug"/> events, <c>false</c> otherwise.
  78. /// </value>
  79. /// <remarks>
  80. /// <para>
  81. /// This function is intended to lessen the computational cost of
  82. /// disabled log debug statements.
  83. /// </para>
  84. /// <para>
  85. /// For some ILog interface <c>log</c>, when you write:
  86. /// </para>
  87. /// <code lang="C#">
  88. /// log.Debug("This is entry number: " + i );
  89. /// </code>
  90. /// <para>
  91. /// You incur the cost constructing the message, string construction and concatenation in
  92. /// this case, regardless of whether the message is logged or not.
  93. /// </para>
  94. /// <para>
  95. /// If you are worried about speed (who isn't), then you should write:
  96. /// </para>
  97. /// <code lang="C#">
  98. /// if (log.IsDebugEnabled)
  99. /// {
  100. /// log.Debug("This is entry number: " + i );
  101. /// }
  102. /// </code>
  103. /// <para>
  104. /// This way you will not incur the cost of parameter
  105. /// construction if debugging is disabled for <c>log</c>. On
  106. /// the other hand, if the <c>log</c> is debug enabled, you
  107. /// will incur the cost of evaluating whether the logger is debug
  108. /// enabled twice. Once in <see cref="P:log4net.ILog.IsDebugEnabled"/> and once in
  109. /// the <see cref="M:log4net.ILog.Debug(System.Object)"/>. This is an insignificant overhead
  110. /// since evaluating a logger takes about 1% of the time it
  111. /// takes to actually log. This is the preferred style of logging.
  112. /// </para>
  113. /// <para>
  114. /// Alternatively if your logger is available statically then the is debug
  115. /// enabled state can be stored in a static variable like this:
  116. /// </para>
  117. /// <code lang="C#">
  118. /// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
  119. /// </code>
  120. /// <para>
  121. /// Then when you come to log you can write:
  122. /// </para>
  123. /// <code lang="C#">
  124. /// if (isDebugEnabled)
  125. /// {
  126. /// log.Debug("This is entry number: " + i );
  127. /// }
  128. /// </code>
  129. /// <para>
  130. /// This way the debug enabled state is only queried once
  131. /// when the class is loaded. Using a <c>private static readonly</c>
  132. /// variable is the most efficient because it is a run time constant
  133. /// and can be heavily optimized by the JIT compiler.
  134. /// </para>
  135. /// <para>
  136. /// Of course if you use a static readonly variable to
  137. /// hold the enabled state of the logger then you cannot
  138. /// change the enabled state at runtime to vary the logging
  139. /// that is produced. You have to decide if you need absolute
  140. /// speed or runtime flexibility.
  141. /// </para>
  142. /// </remarks>
  143. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="M:log4net.ILog.DebugFormat(System.IFormatProvider,System.String,System.Object[])"/>
  144. public static bool IsDebugEnabled
  145. {
  146. get { return Log.IsDebugEnabled; }
  147. }
  148. /// <summary>
  149. /// Checks if this logger is enabled for the <see cref="F:log4net.Core.Level.Info"/> level.
  150. /// </summary>
  151. /// <value>
  152. /// <c>true</c> if this logger is enabled for <see cref="F:log4net.Core.Level.Info"/> events, <c>false</c> otherwise.
  153. /// </value>
  154. /// <remarks>
  155. /// For more information see <see cref="P:log4net.ILog.IsDebugEnabled"/>.
  156. /// </remarks>
  157. /// <seealso cref="M:log4net.ILog.Info(System.Object)"/><seealso cref="M:log4net.ILog.InfoFormat(System.IFormatProvider,System.String,System.Object[])"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  158. public static bool IsInfoEnabled
  159. {
  160. get { return Log.IsInfoEnabled; }
  161. }
  162. /// <summary>
  163. /// Checks if this logger is enabled for the <see cref="F:log4net.Core.Level.Warn"/> level.
  164. /// </summary>
  165. /// <value>
  166. /// <c>true</c> if this logger is enabled for <see cref="F:log4net.Core.Level.Warn"/> events, <c>false</c> otherwise.
  167. /// </value>
  168. /// <remarks>
  169. /// For more information see <see cref="P:log4net.ILog.IsDebugEnabled"/>.
  170. /// </remarks>
  171. /// <seealso cref="M:log4net.ILog.Warn(System.Object)"/><seealso cref="M:log4net.ILog.WarnFormat(System.IFormatProvider,System.String,System.Object[])"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  172. public static bool IsWarnEnabled
  173. {
  174. get { return Log.IsWarnEnabled; }
  175. }
  176. /// <summary>
  177. /// Checks if this logger is enabled for the <see cref="F:log4net.Core.Level.Error"/> level.
  178. /// </summary>
  179. /// <value>
  180. /// <c>true</c> if this logger is enabled for <see cref="F:log4net.Core.Level.Error"/> events, <c>false</c> otherwise.
  181. /// </value>
  182. /// <remarks>
  183. /// For more information see <see cref="P:log4net.ILog.IsDebugEnabled"/>.
  184. /// </remarks>
  185. /// <seealso cref="M:log4net.ILog.Error(System.Object)"/><seealso cref="M:log4net.ILog.ErrorFormat(System.IFormatProvider,System.String,System.Object[])"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  186. public static bool IsErrorEnabled
  187. {
  188. get { return Log.IsErrorEnabled; }
  189. }
  190. /// <summary>
  191. /// Checks if this logger is enabled for the <see cref="F:log4net.Core.Level.Fatal"/> level.
  192. /// </summary>
  193. /// <value>
  194. /// <c>true</c> if this logger is enabled for <see cref="F:log4net.Core.Level.Fatal"/> events, <c>false</c> otherwise.
  195. /// </value>
  196. /// <remarks>
  197. /// For more information see <see cref="P:log4net.ILog.IsDebugEnabled"/>.
  198. /// </remarks>
  199. /// <seealso cref="M:log4net.ILog.Fatal(System.Object)"/><seealso cref="M:log4net.ILog.FatalFormat(System.IFormatProvider,System.String,System.Object[])"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  200. public static bool IsFatalEnabled
  201. {
  202. get { return Log.IsFatalEnabled; }
  203. }
  204. #endregion
  205. #region Methods
  206. //--------------------------------------------------------------------
  207. // Methods
  208. //--------------------------------------------------------------------
  209. /// <overloads>Log a message object with the <see cref="F:log4net.Core.Level.Debug"/> level.</overloads>
  210. /// <summary>
  211. /// Log a message object with the <see cref="F:log4net.Core.Level.Debug"/> level.
  212. /// </summary>
  213. /// <param name="message">The message object to log.</param>
  214. /// <remarks>
  215. /// <para>
  216. /// This method first checks if this logger is <c>DEBUG</c>
  217. /// enabled by comparing the level of this logger with the
  218. /// <see cref="F:log4net.Core.Level.Debug"/> level. If this logger is
  219. /// <c>DEBUG</c> enabled, then it converts the message object
  220. /// (passed as parameter) to a string by invoking the appropriate
  221. /// <see cref="T:log4net.ObjectRenderer.IObjectRenderer"/>. It then
  222. /// proceeds to call all the registered appenders in this logger
  223. /// and also higher in the hierarchy depending on the value of
  224. /// the additivity flag.
  225. /// </para>
  226. /// <para>
  227. /// <b>WARNING</b> Note that passing an <see cref="T:System.Exception"/>
  228. /// to this method will print the name of the <see cref="T:System.Exception"/>
  229. /// but no stack trace. To print a stack trace use the
  230. /// <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/> form instead.
  231. /// </para>
  232. /// </remarks>
  233. /// <seealso cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  234. public static void Debug(object message)
  235. {
  236. Log.Debug(message);
  237. }
  238. /// <summary>
  239. /// Log a message object with the <see cref="F:log4net.Core.Level.Debug"/> level including
  240. /// the stack trace of the <see cref="T:System.Exception"/> passed
  241. /// as a parameter.
  242. /// </summary>
  243. /// <param name="message">The message object to log.</param><param name="exception">The exception to log, including its stack trace.</param>
  244. /// <remarks>
  245. /// <para>
  246. /// See the <see cref="M:log4net.ILog.Debug(System.Object)"/> form for more detailed information.
  247. /// </para>
  248. /// </remarks>
  249. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  250. public static void Debug(object message, Exception exception)
  251. {
  252. Log.Debug(message, exception);
  253. }
  254. /// <overloads>Log a formatted string with the <see cref="F:log4net.Core.Level.Debug"/> level.</overloads>
  255. /// <summary>
  256. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Debug"/> level.
  257. /// </summary>
  258. /// <param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  259. /// <remarks>
  260. /// <para>
  261. /// The message is formatted using the <c>String.Format</c> method. See
  262. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  263. /// of the formatting.
  264. /// </para>
  265. /// <para>
  266. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  267. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/>
  268. /// methods instead.
  269. /// </para>
  270. /// </remarks>
  271. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  272. public static void DebugFormat(string format, params object[] args)
  273. {
  274. Log.DebugFormat(format, args);
  275. }
  276. /// <summary>
  277. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Debug"/> level.
  278. /// </summary>
  279. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param>
  280. /// <remarks>
  281. /// <para>
  282. /// The message is formatted using the <c>String.Format</c> method. See
  283. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  284. /// of the formatting.
  285. /// </para>
  286. /// <para>
  287. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  288. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/>
  289. /// methods instead.
  290. /// </para>
  291. /// </remarks>
  292. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  293. public static void DebugFormat(string format, object arg0)
  294. {
  295. Log.DebugFormat(format, arg0);
  296. }
  297. /// <summary>
  298. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Debug"/> level.
  299. /// </summary>
  300. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param>
  301. /// <remarks>
  302. /// <para>
  303. /// The message is formatted using the <c>String.Format</c> method. See
  304. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  305. /// of the formatting.
  306. /// </para>
  307. /// <para>
  308. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  309. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/>
  310. /// methods instead.
  311. /// </para>
  312. /// </remarks>
  313. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  314. public static void DebugFormat(string format, object arg0, object arg1)
  315. {
  316. Log.DebugFormat(format, arg0, arg1);
  317. }
  318. /// <summary>
  319. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Debug"/> level.
  320. /// </summary>
  321. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param><param name="arg2">An Object to format</param>
  322. /// <remarks>
  323. /// <para>
  324. /// The message is formatted using the <c>String.Format</c> method. See
  325. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  326. /// of the formatting.
  327. /// </para>
  328. /// <para>
  329. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  330. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/>
  331. /// methods instead.
  332. /// </para>
  333. /// </remarks>
  334. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  335. public static void DebugFormat(string format, object arg0, object arg1, object arg2)
  336. {
  337. Log.DebugFormat(format, arg0, arg1, arg2);
  338. }
  339. /// <summary>
  340. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Debug"/> level.
  341. /// </summary>
  342. /// <param name="provider">An <see cref="T:System.IFormatProvider"/> that supplies culture-specific formatting information</param><param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  343. /// <remarks>
  344. /// <para>
  345. /// The message is formatted using the <c>String.Format</c> method. See
  346. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  347. /// of the formatting.
  348. /// </para>
  349. /// <para>
  350. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  351. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Debug(System.Object,System.Exception)"/>
  352. /// methods instead.
  353. /// </para>
  354. /// </remarks>
  355. /// <seealso cref="M:log4net.ILog.Debug(System.Object)"/><seealso cref="P:log4net.ILog.IsDebugEnabled"/>
  356. public static void DebugFormat(IFormatProvider provider, string format, params object[] args)
  357. {
  358. Log.DebugFormat(provider, format, args);
  359. }
  360. /// <overloads>Log a message object with the <see cref="F:log4net.Core.Level.Info"/> level.</overloads>
  361. /// <summary>
  362. /// Logs a message object with the <see cref="F:log4net.Core.Level.Info"/> level.
  363. /// </summary>
  364. /// <remarks>
  365. /// <para>
  366. /// This method first checks if this logger is <c>INFO</c>
  367. /// enabled by comparing the level of this logger with the
  368. /// <see cref="F:log4net.Core.Level.Info"/> level. If this logger is
  369. /// <c>INFO</c> enabled, then it converts the message object
  370. /// (passed as parameter) to a string by invoking the appropriate
  371. /// <see cref="T:log4net.ObjectRenderer.IObjectRenderer"/>. It then
  372. /// proceeds to call all the registered appenders in this logger
  373. /// and also higher in the hierarchy depending on the value of the
  374. /// additivity flag.
  375. /// </para>
  376. /// <para>
  377. /// <b>WARNING</b> Note that passing an <see cref="T:System.Exception"/>
  378. /// to this method will print the name of the <see cref="T:System.Exception"/>
  379. /// but no stack trace. To print a stack trace use the
  380. /// <see cref="M:log4net.ILog.Info(System.Object,System.Exception)"/> form instead.
  381. /// </para>
  382. /// </remarks>
  383. /// <param name="message">The message object to log.</param><seealso cref="M:log4net.ILog.Info(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  384. public static void Info(object message)
  385. {
  386. Log.Info(message);
  387. }
  388. /// <summary>
  389. /// Logs a message object with the <c>INFO</c> level including
  390. /// the stack trace of the <see cref="T:System.Exception"/> passed
  391. /// as a parameter.
  392. /// </summary>
  393. /// <param name="message">The message object to log.</param><param name="exception">The exception to log, including its stack trace.</param>
  394. /// <remarks>
  395. /// <para>
  396. /// See the <see cref="M:log4net.ILog.Info(System.Object)"/> form for more detailed information.
  397. /// </para>
  398. /// </remarks>
  399. /// <seealso cref="M:log4net.ILog.Info(System.Object)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  400. public static void Info(object message, Exception exception)
  401. {
  402. Log.Info(message, exception);
  403. }
  404. /// <overloads>Log a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.</overloads>
  405. /// <summary>
  406. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.
  407. /// </summary>
  408. /// <param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  409. /// <remarks>
  410. /// <para>
  411. /// The message is formatted using the <c>String.Format</c> method. See
  412. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  413. /// of the formatting.
  414. /// </para>
  415. /// <para>
  416. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  417. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Info(System.Object)"/>
  418. /// methods instead.
  419. /// </para>
  420. /// </remarks>
  421. /// <seealso cref="M:log4net.ILog.Info(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  422. public static void InfoFormat(string format, params object[] args)
  423. {
  424. Log.InfoFormat(format, args);
  425. }
  426. /// <summary>
  427. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.
  428. /// </summary>
  429. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param>
  430. /// <remarks>
  431. /// <para>
  432. /// The message is formatted using the <c>String.Format</c> method. See
  433. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  434. /// of the formatting.
  435. /// </para>
  436. /// <para>
  437. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  438. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Info(System.Object,System.Exception)"/>
  439. /// methods instead.
  440. /// </para>
  441. /// </remarks>
  442. /// <seealso cref="M:log4net.ILog.Info(System.Object)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  443. public static void InfoFormat(string format, object arg0)
  444. {
  445. Log.InfoFormat(format, arg0);
  446. }
  447. /// <summary>
  448. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.
  449. /// </summary>
  450. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param>
  451. /// <remarks>
  452. /// <para>
  453. /// The message is formatted using the <c>String.Format</c> method. See
  454. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  455. /// of the formatting.
  456. /// </para>
  457. /// <para>
  458. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  459. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Info(System.Object,System.Exception)"/>
  460. /// methods instead.
  461. /// </para>
  462. /// </remarks>
  463. /// <seealso cref="M:log4net.ILog.Info(System.Object)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  464. public static void InfoFormat(string format, object arg0, object arg1)
  465. {
  466. Log.InfoFormat(format, arg0, arg1);
  467. }
  468. /// <summary>
  469. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.
  470. /// </summary>
  471. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param><param name="arg2">An Object to format</param>
  472. /// <remarks>
  473. /// <para>
  474. /// The message is formatted using the <c>String.Format</c> method. See
  475. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  476. /// of the formatting.
  477. /// </para>
  478. /// <para>
  479. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  480. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Info(System.Object,System.Exception)"/>
  481. /// methods instead.
  482. /// </para>
  483. /// </remarks>
  484. /// <seealso cref="M:log4net.ILog.Info(System.Object)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  485. public static void InfoFormat(string format, object arg0, object arg1, object arg2)
  486. {
  487. Log.InfoFormat(format, arg0, arg1, arg2);
  488. }
  489. /// <summary>
  490. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Info"/> level.
  491. /// </summary>
  492. /// <param name="provider">An <see cref="T:System.IFormatProvider"/> that supplies culture-specific formatting information</param><param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  493. /// <remarks>
  494. /// <para>
  495. /// The message is formatted using the <c>String.Format</c> method. See
  496. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  497. /// of the formatting.
  498. /// </para>
  499. /// <para>
  500. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  501. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Info(System.Object)"/>
  502. /// methods instead.
  503. /// </para>
  504. /// </remarks>
  505. /// <seealso cref="M:log4net.ILog.Info(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsInfoEnabled"/>
  506. public static void InfoFormat(IFormatProvider provider, string format, params object[] args)
  507. {
  508. Log.InfoFormat(provider, format, args);
  509. }
  510. /// <overloads>Log a message object with the <see cref="F:log4net.Core.Level.Warn"/> level.</overloads>
  511. /// <summary>
  512. /// Log a message object with the <see cref="F:log4net.Core.Level.Warn"/> level.
  513. /// </summary>
  514. /// <remarks>
  515. /// <para>
  516. /// This method first checks if this logger is <c>WARN</c>
  517. /// enabled by comparing the level of this logger with the
  518. /// <see cref="F:log4net.Core.Level.Warn"/> level. If this logger is
  519. /// <c>WARN</c> enabled, then it converts the message object
  520. /// (passed as parameter) to a string by invoking the appropriate
  521. /// <see cref="T:log4net.ObjectRenderer.IObjectRenderer"/>. It then
  522. /// proceeds to call all the registered appenders in this logger
  523. /// and also higher in the hierarchy depending on the value of the
  524. /// additivity flag.
  525. /// </para>
  526. /// <para>
  527. /// <b>WARNING</b> Note that passing an <see cref="T:System.Exception"/>
  528. /// to this method will print the name of the <see cref="T:System.Exception"/>
  529. /// but no stack trace. To print a stack trace use the
  530. /// <see cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/> form instead.
  531. /// </para>
  532. /// </remarks>
  533. /// <param name="message">The message object to log.</param><seealso cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  534. public static void Warn(object message)
  535. {
  536. Log.Warn(message);
  537. }
  538. /// <summary>
  539. /// Log a message object with the <see cref="F:log4net.Core.Level.Warn"/> level including
  540. /// the stack trace of the <see cref="T:System.Exception"/> passed
  541. /// as a parameter.
  542. /// </summary>
  543. /// <param name="message">The message object to log.</param><param name="exception">The exception to log, including its stack trace.</param>
  544. /// <remarks>
  545. /// <para>
  546. /// See the <see cref="M:log4net.ILog.Warn(System.Object)"/> form for more detailed information.
  547. /// </para>
  548. /// </remarks>
  549. /// <seealso cref="M:log4net.ILog.Warn(System.Object)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  550. public static void Warn(object message, Exception exception)
  551. {
  552. Log.Warn(message, exception);
  553. }
  554. /// <overloads>Log a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.</overloads>
  555. /// <summary>
  556. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
  557. /// </summary>
  558. /// <param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  559. /// <remarks>
  560. /// <para>
  561. /// The message is formatted using the <c>String.Format</c> method. See
  562. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  563. /// of the formatting.
  564. /// </para>
  565. /// <para>
  566. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  567. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object)"/>
  568. /// methods instead.
  569. /// </para>
  570. /// </remarks>
  571. /// <seealso cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  572. public static void WarnFormat(string format, params object[] args)
  573. {
  574. Log.WarnFormat(format, args);
  575. }
  576. /// <summary>
  577. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
  578. /// </summary>
  579. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param>
  580. /// <remarks>
  581. /// <para>
  582. /// The message is formatted using the <c>String.Format</c> method. See
  583. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  584. /// of the formatting.
  585. /// </para>
  586. /// <para>
  587. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  588. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/>
  589. /// methods instead.
  590. /// </para>
  591. /// </remarks>
  592. /// <seealso cref="M:log4net.ILog.Warn(System.Object)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  593. public static void WarnFormat(string format, object arg0)
  594. {
  595. Log.WarnFormat(format, arg0);
  596. }
  597. /// <summary>
  598. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
  599. /// </summary>
  600. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param>
  601. /// <remarks>
  602. /// <para>
  603. /// The message is formatted using the <c>String.Format</c> method. See
  604. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  605. /// of the formatting.
  606. /// </para>
  607. /// <para>
  608. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  609. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/>
  610. /// methods instead.
  611. /// </para>
  612. /// </remarks>
  613. /// <seealso cref="M:log4net.ILog.Warn(System.Object)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  614. public static void WarnFormat(string format, object arg0, object arg1)
  615. {
  616. Log.WarnFormat(format, arg0, arg1);
  617. }
  618. /// <summary>
  619. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
  620. /// </summary>
  621. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param><param name="arg2">An Object to format</param>
  622. /// <remarks>
  623. /// <para>
  624. /// The message is formatted using the <c>String.Format</c> method. See
  625. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  626. /// of the formatting.
  627. /// </para>
  628. /// <para>
  629. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  630. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/>
  631. /// methods instead.
  632. /// </para>
  633. /// </remarks>
  634. /// <seealso cref="M:log4net.ILog.Warn(System.Object)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  635. public static void WarnFormat(string format, object arg0, object arg1, object arg2)
  636. {
  637. Log.WarnFormat(format, arg0, arg1, arg2);
  638. }
  639. /// <summary>
  640. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Warn"/> level.
  641. /// </summary>
  642. /// <param name="provider">An <see cref="T:System.IFormatProvider"/> that supplies culture-specific formatting information</param><param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  643. /// <remarks>
  644. /// <para>
  645. /// The message is formatted using the <c>String.Format</c> method. See
  646. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  647. /// of the formatting.
  648. /// </para>
  649. /// <para>
  650. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  651. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Warn(System.Object)"/>
  652. /// methods instead.
  653. /// </para>
  654. /// </remarks>
  655. /// <seealso cref="M:log4net.ILog.Warn(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsWarnEnabled"/>
  656. public static void WarnFormat(IFormatProvider provider, string format, params object[] args)
  657. {
  658. Log.WarnFormat(provider, format, args);
  659. }
  660. /// <overloads>Log a message object with the <see cref="F:log4net.Core.Level.Error"/> level.</overloads>
  661. /// <summary>
  662. /// Logs a message object with the <see cref="F:log4net.Core.Level.Error"/> level.
  663. /// </summary>
  664. /// <param name="message">The message object to log.</param>
  665. /// <remarks>
  666. /// <para>
  667. /// This method first checks if this logger is <c>ERROR</c>
  668. /// enabled by comparing the level of this logger with the
  669. /// <see cref="F:log4net.Core.Level.Error"/> level. If this logger is
  670. /// <c>ERROR</c> enabled, then it converts the message object
  671. /// (passed as parameter) to a string by invoking the appropriate
  672. /// <see cref="T:log4net.ObjectRenderer.IObjectRenderer"/>. It then
  673. /// proceeds to call all the registered appenders in this logger
  674. /// and also higher in the hierarchy depending on the value of the
  675. /// additivity flag.
  676. /// </para>
  677. /// <para>
  678. /// <b>WARNING</b> Note that passing an <see cref="T:System.Exception"/>
  679. /// to this method will print the name of the <see cref="T:System.Exception"/>
  680. /// but no stack trace. To print a stack trace use the
  681. /// <see cref="M:log4net.ILog.Error(System.Object,System.Exception)"/> form instead.
  682. /// </para>
  683. /// </remarks>
  684. /// <seealso cref="M:log4net.ILog.Error(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  685. public static void Error(object message)
  686. {
  687. Log.Error(message);
  688. }
  689. /// <summary>
  690. /// Log a message object with the <see cref="F:log4net.Core.Level.Error"/> level including
  691. /// the stack trace of the <see cref="T:System.Exception"/> passed
  692. /// as a parameter.
  693. /// </summary>
  694. /// <param name="message">The message object to log.</param><param name="exception">The exception to log, including its stack trace.</param>
  695. /// <remarks>
  696. /// <para>
  697. /// See the <see cref="M:log4net.ILog.Error(System.Object)"/> form for more detailed information.
  698. /// </para>
  699. /// </remarks>
  700. /// <seealso cref="M:log4net.ILog.Error(System.Object)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  701. public static void Error(object message, Exception exception)
  702. {
  703. Log.Error(message, exception);
  704. }
  705. /// <overloads>Log a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.</overloads>
  706. /// <summary>
  707. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.
  708. /// </summary>
  709. /// <param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  710. /// <remarks>
  711. /// <para>
  712. /// The message is formatted using the <c>String.Format</c> method. See
  713. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  714. /// of the formatting.
  715. /// </para>
  716. /// <para>
  717. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  718. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Error(System.Object)"/>
  719. /// methods instead.
  720. /// </para>
  721. /// </remarks>
  722. /// <seealso cref="M:log4net.ILog.Error(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  723. public static void ErrorFormat(string format, params object[] args)
  724. {
  725. Log.ErrorFormat(format, args);
  726. }
  727. /// <summary>
  728. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.
  729. /// </summary>
  730. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param>
  731. /// <remarks>
  732. /// <para>
  733. /// The message is formatted using the <c>String.Format</c> method. See
  734. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  735. /// of the formatting.
  736. /// </para>
  737. /// <para>
  738. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  739. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Error(System.Object,System.Exception)"/>
  740. /// methods instead.
  741. /// </para>
  742. /// </remarks>
  743. /// <seealso cref="M:log4net.ILog.Error(System.Object)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  744. public static void ErrorFormat(string format, object arg0)
  745. {
  746. Log.ErrorFormat(format, arg0);
  747. }
  748. /// <summary>
  749. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.
  750. /// </summary>
  751. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param>
  752. /// <remarks>
  753. /// <para>
  754. /// The message is formatted using the <c>String.Format</c> method. See
  755. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  756. /// of the formatting.
  757. /// </para>
  758. /// <para>
  759. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  760. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Error(System.Object,System.Exception)"/>
  761. /// methods instead.
  762. /// </para>
  763. /// </remarks>
  764. /// <seealso cref="M:log4net.ILog.Error(System.Object)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  765. public static void ErrorFormat(string format, object arg0, object arg1)
  766. {
  767. Log.ErrorFormat(format, arg0, arg1);
  768. }
  769. /// <summary>
  770. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.
  771. /// </summary>
  772. /// <param name="format">A String containing zero or more format items</param><param name="arg0">An Object to format</param><param name="arg1">An Object to format</param><param name="arg2">An Object to format</param>
  773. /// <remarks>
  774. /// <para>
  775. /// The message is formatted using the <c>String.Format</c> method. See
  776. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  777. /// of the formatting.
  778. /// </para>
  779. /// <para>
  780. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  781. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Error(System.Object,System.Exception)"/>
  782. /// methods instead.
  783. /// </para>
  784. /// </remarks>
  785. /// <seealso cref="M:log4net.ILog.Error(System.Object)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  786. public static void ErrorFormat(string format, object arg0, object arg1, object arg2)
  787. {
  788. Log.ErrorFormat(format, arg0, arg1, arg2);
  789. }
  790. /// <summary>
  791. /// Logs a formatted message string with the <see cref="F:log4net.Core.Level.Error"/> level.
  792. /// </summary>
  793. /// <param name="provider">An <see cref="T:System.IFormatProvider"/> that supplies culture-specific formatting information</param><param name="format">A String containing zero or more format items</param><param name="args">An Object array containing zero or more objects to format</param>
  794. /// <remarks>
  795. /// <para>
  796. /// The message is formatted using the <c>String.Format</c> method. See
  797. /// <see cref="M:System.String.Format(System.String,System.Object[])"/> for details of the syntax of the format string and the behavior
  798. /// of the formatting.
  799. /// </para>
  800. /// <para>
  801. /// This method does not take an <see cref="T:System.Exception"/> object to include in the
  802. /// log event. To pass an <see cref="T:System.Exception"/> use one of the <see cref="M:log4net.ILog.Error(System.Object)"/>
  803. /// methods instead.
  804. /// </para>
  805. /// </remarks>
  806. /// <seealso cref="M:log4net.ILog.Error(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsErrorEnabled"/>
  807. public static void ErrorFormat(IFormatProvider provider, string format, params object[] args)
  808. {
  809. Log.ErrorFormat(provider, format, args);
  810. }
  811. /// <overloads>Log a message object with the <see cref="F:log4net.Core.Level.Fatal"/> level.</overloads>
  812. /// <summary>
  813. /// Log a message object with the <see cref="F:log4net.Core.Level.Fatal"/> level.
  814. /// </summary>
  815. /// <remarks>
  816. /// <para>
  817. /// This method first checks if this logger is <c>FATAL</c>
  818. /// enabled by comparing the level of this logger with the
  819. /// <see cref="F:log4net.Core.Level.Fatal"/> level. If this logger is
  820. /// <c>FATAL</c> enabled, then it converts the message object
  821. /// (passed as parameter) to a string by invoking the appropriate
  822. /// <see cref="T:log4net.ObjectRenderer.IObjectRenderer"/>. It then
  823. /// proceeds to call all the registered appenders in this logger
  824. /// and also higher in the hierarchy depending on the value of the
  825. /// additivity flag.
  826. /// </para>
  827. /// <para>
  828. /// <b>WARNING</b> Note that passing an <see cref="T:System.Exception"/>
  829. /// to this method will print the name of the <see cref="T:System.Exception"/>
  830. /// but no stack trace. To print a stack trace use the
  831. /// <see cref="M:log4net.ILog.Fatal(System.Object,System.Exception)"/> form instead.
  832. /// </para>
  833. /// </remarks>
  834. /// <param name="message">The message object to log.</param><seealso cref="M:log4net.ILog.Fatal(System.Object,System.Exception)"/><seealso cref="P:log4net.ILog.IsFatalEnabled"/>
  835. public static void Fatal(object message)
  836. {
  837. Log.Fatal(message);
  838. }
  839. /// <summary>
  840. /// Log a message object with the <see cref="F:log4net.Core.Level.Fatal"/> level including
  841. /// the stack trace of the <see cref="T:System.Exception"/> passed
  842. /// as a parameter.
  843. /// </…

Large files files are truncated, but you can click here to view the full file