コード例 #1
0
        /// <summary>
        /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
        /// </summary>
        /// <param name="level">The level to check.</param>
        /// <returns>
        /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
        /// </returns>
        /// <remarks>
        /// <para>
        /// Test if this logger is going to log events of the specified <paramref name="level"/>.
        /// </para>
        /// <para>
        /// This method must not throw any exception to the caller.
        /// </para>
        /// </remarks>
        virtual public bool IsEnabledFor(Level level)
        {
            try
            {
                if (level != null)
                {
                    if (Hierarchy.IsDisabled(level))
                    {
                        return(false);
                    }
                    return(level >= this.EffectiveLevel);
                }
            }
            catch (Exception ex)
            {
                log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
            }
#if NETCF
            catch
            {
                log4net.Util.LogLog.Error(declaringType, "Exception while logging");
            }
#endif
            return(false);
        }
コード例 #2
0
ファイル: Logger.cs プロジェクト: bzmework/log4net
 /// <summary>
 /// Checks if this logger is enabled for a given <see cref="P:log4net.Repository.Hierarchy.Logger.Level" /> passed as parameter.
 /// </summary>
 /// <param name="level">The level to check.</param>
 /// <returns>
 /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
 /// </returns>
 /// <remarks>
 /// <para>
 /// Test if this logger is going to log events of the specified <paramref name="level" />.
 /// </para>
 /// <para>
 /// This method must not throw any exception to the caller.
 /// </para>
 /// </remarks>
 public virtual bool IsEnabledFor(Level level)
 {
     try
     {
         if (level != null)
         {
             if (m_hierarchy.IsDisabled(level))
             {
                 return(false);
             }
             return(level >= EffectiveLevel);
         }
     }
     catch (Exception exception)
     {
         LogLog.Error(declaringType, "Exception while logging", exception);
     }
     return(false);
 }