#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
{
///
/// Implementation of wrapper interface.
///
///
///
/// This implementation of the interface
/// forwards to the held by the base class.
///
///
/// This logger has methods to allow the caller to log at the following
/// levels:
///
///
/// -
/// DEBUG
///
/// The and methods log messages
/// at the DEBUG level. That is the level with that name defined in the
/// repositories . The default value
/// for this level is . The
/// property tests if this level is enabled for logging.
///
///
/// -
/// INFO
///
/// The and methods log messages
/// at the INFO level. That is the level with that name defined in the
/// repositories . The default value
/// for this level is . The
/// property tests if this level is enabled for logging.
///
///
/// -
/// WARN
///
/// The and methods log messages
/// at the WARN level. That is the level with that name defined in the
/// repositories . The default value
/// for this level is . The
/// property tests if this level is enabled for logging.
///
///
/// -
/// ERROR
///
/// The and methods log messages
/// at the ERROR level. That is the level with that name defined in the
/// repositories . The default value
/// for this level is . The
/// property tests if this level is enabled for logging.
///
///
/// -
/// FATAL
///
/// The and methods log messages
/// at the FATAL level. That is the level with that name defined in the
/// repositories . The default value
/// for this level is . The
/// property tests if this level is enabled for logging.
///
///
///
///
/// The values for these levels and their semantic meanings can be changed by
/// configuring the for the repository.
///
///
/// Nicko Cadell
/// Gert Driesen
public class LogImpl : LoggerWrapperImpl, ILog
{
#region Public Instance Constructors
///
/// Construct a new wrapper for the specified logger.
///
/// The logger to wrap.
///
///
/// Construct a new wrapper for the specified logger.
///
///
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
///
/// Virtual method called when the configuration of the repository changes
///
/// the repository holding the levels
///
///
/// Virtual method called when the configuration of the repository changes
///
///
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
///
/// Logs a message object with the DEBUG level.
///
/// The message object to log.
///
///
/// This method first checks if this logger is DEBUG
/// enabled by comparing the level of this logger with the
/// DEBUG level. If this logger is
/// DEBUG enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// . 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.
///
///
/// WARNING Note that passing an
/// to this method will print the name of the
/// but no stack trace. To print a stack trace use the
/// form instead.
///
///
public virtual void Debug(object message)
{
Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
}
///
/// Logs a message object with the DEBUG level
///
/// The message object to log.
/// The exception to log, including its stack trace.
///
///
/// Logs a message object with the DEBUG level including
/// the stack trace of the passed
/// as a parameter.
///
///
/// See the form for more detailed information.
///
///
///
public virtual void Debug(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
}
///
/// Logs a formatted message string with the DEBUG level.
///
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void DebugFormat(string format, params object[] args)
{
if (IsDebugEnabled)
{
Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
///
/// Logs a formatted message string with the DEBUG level.
///
/// A String containing zero or more format items
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void DebugFormat(string format, object arg0)
{
if (IsDebugEnabled)
{
Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
}
}
///
/// Logs a formatted message string with the DEBUG level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the DEBUG level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the DEBUG level.
///
/// An that supplies culture-specific formatting information
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void DebugFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsDebugEnabled)
{
Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
}
}
///
/// Logs a message object with the INFO level.
///
/// The message object to log.
///
///
/// This method first checks if this logger is INFO
/// enabled by comparing the level of this logger with the
/// INFO level. If this logger is
/// INFO enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// . 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.
///
///
/// WARNING Note that passing an
/// to this method will print the name of the
/// but no stack trace. To print a stack trace use the
/// form instead.
///
///
public virtual void Info(object message)
{
Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
}
///
/// Logs a message object with the INFO level.
///
/// The message object to log.
/// The exception to log, including its stack trace.
///
///
/// Logs a message object with the INFO level including
/// the stack trace of the
/// passed as a parameter.
///
///
/// See the form for more detailed information.
///
///
///
public virtual void Info(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
}
///
/// Logs a formatted message string with the INFO level.
///
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void InfoFormat(string format, params object[] args)
{
if (IsInfoEnabled)
{
Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
///
/// Logs a formatted message string with the INFO level.
///
/// A String containing zero or more format items
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void InfoFormat(string format, object arg0)
{
if (IsInfoEnabled)
{
Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
}
}
///
/// Logs a formatted message string with the INFO level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the INFO level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the INFO level.
///
/// An that supplies culture-specific formatting information
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void InfoFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsInfoEnabled)
{
Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
}
}
///
/// Logs a message object with the WARN level.
///
/// the message object to log
///
///
/// This method first checks if this logger is WARN
/// enabled by comparing the level of this logger with the
/// WARN level. If this logger is
/// WARN enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// . 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.
///
///
/// WARNING Note that passing an to this
/// method will print the name of the but no
/// stack trace. To print a stack trace use the
/// form instead.
///
///
public virtual void Warn(object message)
{
Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
}
///
/// Logs a message object with the WARN level
///
/// The message object to log.
/// The exception to log, including its stack trace.
///
///
/// Logs a message object with the WARN level including
/// the stack trace of the
/// passed as a parameter.
///
///
/// See the form for more detailed information.
///
///
///
public virtual void Warn(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
}
///
/// Logs a formatted message string with the WARN level.
///
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void WarnFormat(string format, params object[] args)
{
if (IsWarnEnabled)
{
Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
///
/// Logs a formatted message string with the WARN level.
///
/// A String containing zero or more format items
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void WarnFormat(string format, object arg0)
{
if (IsWarnEnabled)
{
Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
}
}
///
/// Logs a formatted message string with the WARN level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the WARN level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the WARN level.
///
/// An that supplies culture-specific formatting information
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void WarnFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsWarnEnabled)
{
Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
}
}
///
/// Logs a message object with the ERROR level.
///
/// The message object to log.
///
///
/// This method first checks if this logger is ERROR
/// enabled by comparing the level of this logger with the
/// ERROR level. If this logger is
/// ERROR enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// . 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.
///
///
/// WARNING Note that passing an to this
/// method will print the name of the but no
/// stack trace. To print a stack trace use the
/// form instead.
///
///
public virtual void Error(object message)
{
Logger.Log(ThisDeclaringType, m_levelError, message, null);
}
///
/// Logs a message object with the ERROR level
///
/// The message object to log.
/// The exception to log, including its stack trace.
///
///
/// Logs a message object with the ERROR level including
/// the stack trace of the
/// passed as a parameter.
///
///
/// See the form for more detailed information.
///
///
///
public virtual void Error(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelError, message, exception);
}
///
/// Logs a formatted message string with the ERROR level.
///
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void ErrorFormat(string format, params object[] args)
{
if (IsErrorEnabled)
{
Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
///
/// Logs a formatted message string with the ERROR level.
///
/// A String containing zero or more format items
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void ErrorFormat(string format, object arg0)
{
if (IsErrorEnabled)
{
Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
}
}
///
/// Logs a formatted message string with the ERROR level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the ERROR level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the ERROR level.
///
/// An that supplies culture-specific formatting information
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void ErrorFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsErrorEnabled)
{
Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
}
}
///
/// Logs a message object with the FATAL level.
///
/// The message object to log.
///
///
/// This method first checks if this logger is FATAL
/// enabled by comparing the level of this logger with the
/// FATAL level. If this logger is
/// FATAL enabled, then it converts the message object
/// (passed as parameter) to a string by invoking the appropriate
/// . 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.
///
///
/// WARNING Note that passing an to this
/// method will print the name of the but no
/// stack trace. To print a stack trace use the
/// form instead.
///
///
public virtual void Fatal(object message)
{
Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
}
///
/// Logs a message object with the FATAL level
///
/// The message object to log.
/// The exception to log, including its stack trace.
///
///
/// Logs a message object with the FATAL level including
/// the stack trace of the
/// passed as a parameter.
///
///
/// See the form for more detailed information.
///
///
///
public virtual void Fatal(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
}
///
/// Logs a formatted message string with the FATAL level.
///
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void FatalFormat(string format, params object[] args)
{
if (IsFatalEnabled)
{
Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
}
}
///
/// Logs a formatted message string with the FATAL level.
///
/// A String containing zero or more format items
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void FatalFormat(string format, object arg0)
{
if (IsFatalEnabled)
{
Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
}
}
///
/// Logs a formatted message string with the FATAL level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the FATAL level.
///
/// A String containing zero or more format items
/// An Object to format
/// An Object to format
/// An Object to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// The string is formatted using the
/// format provider. To specify a localized provider use the
/// method.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual 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);
}
}
///
/// Logs a formatted message string with the FATAL level.
///
/// An that supplies culture-specific formatting information
/// A String containing zero or more format items
/// An Object array containing zero or more objects to format
///
///
/// The message is formatted using the method. See
/// String.Format for details of the syntax of the format string and the behavior
/// of the formatting.
///
///
/// This method does not take an object to include in the
/// log event. To pass an use one of the
/// methods instead.
///
///
public virtual void FatalFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsFatalEnabled)
{
Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
}
}
///
/// Checks if this logger is enabled for the DEBUG
/// level.
///
///
/// true if this logger is enabled for DEBUG events,
/// false otherwise.
///
///
///
/// This function is intended to lessen the computational cost of
/// disabled log debug statements.
///
///
/// For some log Logger object, when you write:
///
///
/// log.Debug("This is entry number: " + i );
///
///
/// You incur the cost constructing the message, concatenation in
/// this case, regardless of whether the message is logged or not.
///
///
/// If you are worried about speed, then you should write:
///
///
/// if (log.IsDebugEnabled())
/// {
/// log.Debug("This is entry number: " + i );
/// }
///
///
/// This way you will not incur the cost of parameter
/// construction if debugging is disabled for log. On
/// the other hand, if the log is debug enabled, you
/// will incur the cost of evaluating whether the logger is debug
/// enabled twice. Once in IsDebugEnabled and once in
/// the Debug. This is an insignificant overhead
/// since evaluating a logger takes about 1% of the time it
/// takes to actually log.
///
///
public virtual bool IsDebugEnabled
{
get { return Logger.IsEnabledFor(m_levelDebug); }
}
///
/// Checks if this logger is enabled for the INFO level.
///
///
/// true if this logger is enabled for INFO events,
/// false otherwise.
///
///
///
/// See for more information and examples
/// of using this method.
///
///
///
public virtual bool IsInfoEnabled
{
get { return Logger.IsEnabledFor(m_levelInfo); }
}
///
/// Checks if this logger is enabled for the WARN level.
///
///
/// true if this logger is enabled for WARN events,
/// false otherwise.
///
///
///
/// See for more information and examples
/// of using this method.
///
///
///
public virtual bool IsWarnEnabled
{
get { return Logger.IsEnabledFor(m_levelWarn); }
}
///
/// Checks if this logger is enabled for the ERROR level.
///
///
/// true if this logger is enabled for ERROR events,
/// false otherwise.
///
///
///
/// See for more information and examples of using this method.
///
///
///
public virtual bool IsErrorEnabled
{
get { return Logger.IsEnabledFor(m_levelError); }
}
///
/// Checks if this logger is enabled for the FATAL level.
///
///
/// true if this logger is enabled for FATAL events,
/// false otherwise.
///
///
///
/// See for more information and examples of using this method.
///
///
///
public virtual bool IsFatalEnabled
{
get { return Logger.IsEnabledFor(m_levelFatal); }
}
#endregion Implementation of ILog
#region Private Methods
///
/// Event handler for the event
///
/// the repository
/// Empty
private void LoggerRepositoryConfigurationChanged(object sender, EventArgs e)
{
ILoggerRepository repository = sender as ILoggerRepository;
if (repository != null)
{
ReloadLevels(repository);
}
}
#endregion
#region Private Static Instance Fields
///
/// The fully qualified name of this declaring type not the type of any subclass.
///
private static readonly 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
}
}