📄 logimpl.cs
字号:
/// passed as a parameter.
/// </para>
/// <para>
/// See the <see cref="Fatal(object)"/> form for more detailed information.
/// </para>
/// </remarks>
/// <seealso cref="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="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="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="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="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="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="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="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="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="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="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="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="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="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="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
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -