ILogger.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 log4net.Core;
  21. using log4net.Repository;
  22. namespace log4net.Core
  23. {
  24. /// <summary>
  25. /// Interface that all loggers implement
  26. /// </summary>
  27. /// <remarks>
  28. /// <para>
  29. /// This interface supports logging events and testing if a level
  30. /// is enabled for logging.
  31. /// </para>
  32. /// <para>
  33. /// These methods will not throw exceptions. Note to implementor, ensure
  34. /// that the implementation of these methods cannot allow an exception
  35. /// to be thrown to the caller.
  36. /// </para>
  37. /// </remarks>
  38. /// <author>Nicko Cadell</author>
  39. /// <author>Gert Driesen</author>
  40. public interface ILogger
  41. {
  42. /// <summary>
  43. /// Gets the name of the logger.
  44. /// </summary>
  45. /// <value>
  46. /// The name of the logger.
  47. /// </value>
  48. /// <remarks>
  49. /// <para>
  50. /// The name of this logger
  51. /// </para>
  52. /// </remarks>
  53. string Name { get; }
  54. /// <summary>
  55. /// This generic form is intended to be used by wrappers.
  56. /// </summary>
  57. /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
  58. /// the stack boundary into the logging system for this call.</param>
  59. /// <param name="level">The level of the message to be logged.</param>
  60. /// <param name="message">The message object to log.</param>
  61. /// <param name="exception">the exception to log, including its stack trace. Pass <c>null</c> to not log an exception.</param>
  62. /// <remarks>
  63. /// <para>
  64. /// Generates a logging event for the specified <paramref name="level"/> using
  65. /// the <paramref name="message"/> and <paramref name="exception"/>.
  66. /// </para>
  67. /// </remarks>
  68. void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception);
  69. /// <summary>
  70. /// This is the most generic printing method that is intended to be used
  71. /// by wrappers.
  72. /// </summary>
  73. /// <param name="logEvent">The event being logged.</param>
  74. /// <remarks>
  75. /// <para>
  76. /// Logs the specified logging event through this logger.
  77. /// </para>
  78. /// </remarks>
  79. void Log(LoggingEvent logEvent);
  80. /// <summary>
  81. /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
  82. /// </summary>
  83. /// <param name="level">The level to check.</param>
  84. /// <returns>
  85. /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
  86. /// </returns>
  87. /// <remarks>
  88. /// <para>
  89. /// Test if this logger is going to log events of the specified <paramref name="level"/>.
  90. /// </para>
  91. /// </remarks>
  92. bool IsEnabledFor(Level level);
  93. /// <summary>
  94. /// Gets the <see cref="ILoggerRepository"/> where this
  95. /// <c>Logger</c> instance is attached to.
  96. /// </summary>
  97. /// <value>
  98. /// The <see cref="ILoggerRepository" /> that this logger belongs to.
  99. /// </value>
  100. /// <remarks>
  101. /// <para>
  102. /// Gets the <see cref="ILoggerRepository"/> where this
  103. /// <c>Logger</c> instance is attached to.
  104. /// </para>
  105. /// </remarks>
  106. ILoggerRepository Repository { get; }
  107. }
  108. }