123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 |
- #region Apache License
- //
- // Licensed to the Apache Software Foundation (ASF) under one or more
- // contributor license agreements. See the NOTICE file distributed with
- // this work for additional information regarding copyright ownership.
- // The ASF licenses this file to you under the Apache License, Version 2.0
- // (the "License"); you may not use this file except in compliance with
- // the License. You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- //
- #endregion
- using System;
- using System.Globalization;
- using log4net.Repository;
- using log4net.Util;
- namespace log4net.Core
- {
- /// <summary>
- /// Implementation of <see cref="ILog"/> wrapper interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This implementation of the <see cref="ILog"/> interface
- /// forwards to the <see cref="ILogger"/> held by the base class.
- /// </para>
- /// <para>
- /// This logger has methods to allow the caller to log at the following
- /// levels:
- /// </para>
- /// <list type="definition">
- /// <item>
- /// <term>DEBUG</term>
- /// <description>
- /// The <see cref="M:Debug(object)"/> and <see cref="M:DebugFormat(string, object[])"/> methods log messages
- /// at the <c>DEBUG</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Debug"/>. The <see cref="IsDebugEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>INFO</term>
- /// <description>
- /// The <see cref="M:Info(object)"/> and <see cref="M:InfoFormat(string, object[])"/> methods log messages
- /// at the <c>INFO</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Info"/>. The <see cref="IsInfoEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>WARN</term>
- /// <description>
- /// The <see cref="M:Warn(object)"/> and <see cref="M:WarnFormat(string, object[])"/> methods log messages
- /// at the <c>WARN</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Warn"/>. The <see cref="IsWarnEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>ERROR</term>
- /// <description>
- /// The <see cref="M:Error(object)"/> and <see cref="M:ErrorFormat(string, object[])"/> methods log messages
- /// at the <c>ERROR</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Error"/>. The <see cref="IsErrorEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>FATAL</term>
- /// <description>
- /// The <see cref="M:Fatal(object)"/> and <see cref="M:FatalFormat(string, object[])"/> methods log messages
- /// at the <c>FATAL</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Fatal"/>. The <see cref="IsFatalEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// </list>
- /// <para>
- /// The values for these levels and their semantic meanings can be changed by
- /// configuring the <see cref="ILoggerRepository.LevelMap"/> for the repository.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class LogImpl : LoggerWrapperImpl, ILog
- {
- #region Public Instance Constructors
- /// <summary>
- /// Construct a new wrapper for the specified logger.
- /// </summary>
- /// <param name="logger">The logger to wrap.</param>
- /// <remarks>
- /// <para>
- /// Construct a new wrapper for the specified logger.
- /// </para>
- /// </remarks>
- public LogImpl(ILogger logger) : base(logger)
- {
- // Listen for changes to the repository
- logger.Repository.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(LoggerRepositoryConfigurationChanged);
- // load the current levels
- ReloadLevels(logger.Repository);
- }
- #endregion Public Instance Constructors
- /// <summary>
- /// Virtual method called when the configuration of the repository changes
- /// </summary>
- /// <param name="repository">the repository holding the levels</param>
- /// <remarks>
- /// <para>
- /// Virtual method called when the configuration of the repository changes
- /// </para>
- /// </remarks>
- protected virtual void ReloadLevels(ILoggerRepository repository)
- {
- LevelMap levelMap = repository.LevelMap;
- m_levelDebug = levelMap.LookupWithDefault(Level.Debug);
- m_levelInfo = levelMap.LookupWithDefault(Level.Info);
- m_levelWarn = levelMap.LookupWithDefault(Level.Warn);
- m_levelError = levelMap.LookupWithDefault(Level.Error);
- m_levelFatal = levelMap.LookupWithDefault(Level.Fatal);
- }
- #region Implementation of ILog
- /// <summary>
- /// Logs a message object with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>DEBUG</c>
- /// enabled by comparing the level of this logger with the
- /// <c>DEBUG</c> level. If this logger is
- /// <c>DEBUG</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Debug(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- virtual public void Debug(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
- }
- /// <summary>
- /// Logs a message object with the <c>DEBUG</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>DEBUG</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/> passed
- /// as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Debug(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- virtual public void Debug(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
- }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void DebugFormat(string format, params object[] args)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void DebugFormat(string format, object arg0)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void DebugFormat(string format, object arg0, object arg1)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void DebugFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void DebugFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
- }
- }
- /// <summary>
- /// Logs a message object with the <c>INFO</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by comparing the level of this logger with the
- /// <c>INFO</c> level. If this logger is
- /// <c>INFO</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Info(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- virtual public void Info(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
- }
-
- /// <summary>
- /// Logs a message object with the <c>INFO</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>INFO</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Info(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- virtual public void Info(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
- }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void InfoFormat(string format, params object[] args)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void InfoFormat(string format, object arg0)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void InfoFormat(string format, object arg0, object arg1)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void InfoFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void InfoFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
- }
- }
- /// <summary>
- /// Logs a message object with the <c>WARN</c> level.
- /// </summary>
- /// <param name="message">the message object to log</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>WARN</c>
- /// enabled by comparing the level of this logger with the
- /// <c>WARN</c> level. If this logger is
- /// <c>WARN</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Warn(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- virtual public void Warn(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
- }
-
- /// <summary>
- /// Logs a message object with the <c>WARN</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>WARN</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Warn(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- virtual public void Warn(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
- }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void WarnFormat(string format, params object[] args)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void WarnFormat(string format, object arg0)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void WarnFormat(string format, object arg0, object arg1)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void WarnFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void WarnFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
- }
- }
- /// <summary>
- /// Logs a message object with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>ERROR</c>
- /// enabled by comparing the level of this logger with the
- /// <c>ERROR</c> level. If this logger is
- /// <c>ERROR</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Error(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- virtual public void Error(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelError, message, null);
- }
- /// <summary>
- /// Logs a message object with the <c>ERROR</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>ERROR</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Error(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- virtual public void Error(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelError, message, exception);
- }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void ErrorFormat(string format, params object[] args)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void ErrorFormat(string format, object arg0)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void ErrorFormat(string format, object arg0, object arg1)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void ErrorFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void ErrorFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
- }
- }
- /// <summary>
- /// Logs a message object with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>FATAL</c>
- /// enabled by comparing the level of this logger with the
- /// <c>FATAL</c> level. If this logger is
- /// <c>FATAL</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Fatal(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- virtual public void Fatal(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
- }
-
- /// <summary>
- /// Logs a message object with the <c>FATAL</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>FATAL</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- virtual public void Fatal(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
- }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void FatalFormat(string format, params object[] args)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void FatalFormat(string format, object arg0)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void FatalFormat(string format, object arg0, object arg1)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void FatalFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="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>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- virtual public void FatalFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
- }
- }
- /// <summary>
- /// Checks if this logger is enabled for the <c>DEBUG</c>
- /// level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>DEBUG</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// This function is intended to lessen the computational cost of
- /// disabled log debug statements.
- /// </para>
- /// <para>
- /// For some <c>log</c> Logger object, when you write:
- /// </para>
- /// <code lang="C#">
- /// log.Debug("This is entry number: " + i );
- /// </code>
- /// <para>
- /// You incur the cost constructing the message, concatenation in
- /// this case, regardless of whether the message is logged or not.
- /// </para>
- /// <para>
- /// If you are worried about speed, then you should write:
- /// </para>
- /// <code lang="C#">
- /// if (log.IsDebugEnabled())
- /// {
- /// log.Debug("This is entry number: " + i );
- /// }
- /// </code>
- /// <para>
- /// This way you will not incur the cost of parameter
- /// construction if debugging is disabled for <c>log</c>. On
- /// the other hand, if the <c>log</c> is debug enabled, you
- /// will incur the cost of evaluating whether the logger is debug
- /// enabled twice. Once in <c>IsDebugEnabled</c> and once in
- /// the <c>Debug</c>. This is an insignificant overhead
- /// since evaluating a logger takes about 1% of the time it
- /// takes to actually log.
- /// </para>
- /// </remarks>
- virtual public bool IsDebugEnabled
- {
- get { return Logger.IsEnabledFor(m_levelDebug); }
- }
-
- /// <summary>
- /// Checks if this logger is enabled for the <c>INFO</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>INFO</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples
- /// of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="LogImpl.IsDebugEnabled"/>
- virtual public bool IsInfoEnabled
- {
- get { return Logger.IsEnabledFor(m_levelInfo); }
- }
- /// <summary>
- /// Checks if this logger is enabled for the <c>WARN</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>WARN</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples
- /// of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- virtual public bool IsWarnEnabled
- {
- get { return Logger.IsEnabledFor(m_levelWarn); }
- }
- /// <summary>
- /// Checks if this logger is enabled for the <c>ERROR</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>ERROR</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- virtual public bool IsErrorEnabled
- {
- get { return Logger.IsEnabledFor(m_levelError); }
- }
- /// <summary>
- /// Checks if this logger is enabled for the <c>FATAL</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>FATAL</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- virtual public bool IsFatalEnabled
- {
- get { return Logger.IsEnabledFor(m_levelFatal); }
- }
- #endregion Implementation of ILog
- #region Private Methods
- /// <summary>
- /// Event handler for the <see cref="log4net.Repository.ILoggerRepository.ConfigurationChanged"/> event
- /// </summary>
- /// <param name="sender">the repository</param>
- /// <param name="e">Empty</param>
- private void LoggerRepositoryConfigurationChanged(object sender, EventArgs e)
- {
- ILoggerRepository repository = sender as ILoggerRepository;
- if (repository != null)
- {
- ReloadLevels(repository);
- }
- }
- #endregion
- #region Private Static Instance Fields
- /// <summary>
- /// The fully qualified name of this declaring type not the type of any subclass.
- /// </summary>
- private readonly static Type ThisDeclaringType = typeof(LogImpl);
- #endregion Private Static Instance Fields
- #region Private Fields
- private Level m_levelDebug;
- private Level m_levelInfo;
- private Level m_levelWarn;
- private Level m_levelError;
- private Level m_levelFatal;
- #endregion
- }
- }
|