Beispiel #1
0
 public void RemoveAllAppenders()
 {
     if (this.m_appenderList != null)
     {
         AppenderCollection.IAppenderCollectionEnumerator enumerator = this.m_appenderList.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 IAppender current = enumerator.Current;
                 try
                 {
                     current.Close();
                 }
                 catch (Exception exception)
                 {
                     LogLog.Error(declaringType, "Failed to Close appender [" + current.Name + "]", exception);
                 }
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         this.m_appenderList  = null;
         this.m_appenderArray = null;
     }
 }
Beispiel #2
0
 public IAppender GetAppender(string name)
 {
     if ((this.m_appenderList != null) && (name != null))
     {
         AppenderCollection.IAppenderCollectionEnumerator enumerator = this.m_appenderList.GetEnumerator();
         try
         {
             while (true)
             {
                 if (!enumerator.MoveNext())
                 {
                     break;
                 }
                 IAppender current = enumerator.Current;
                 if (name == current.Name)
                 {
                     return(current);
                 }
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// Closes all attached appenders implementing the <see cref="T:log4net.Core.IAppenderAttachable" /> interface.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Used to ensure that the appenders are correctly shutdown.
 /// </para>
 /// </remarks>
 public virtual void CloseNestedAppenders()
 {
     m_appenderLock.AcquireWriterLock();
     try
     {
         if (m_appenderAttachedImpl != null)
         {
             AppenderCollection.IAppenderCollectionEnumerator enumerator = m_appenderAttachedImpl.Appenders.GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     IAppender current = enumerator.Current;
                     if (current is IAppenderAttachable)
                     {
                         current.Close();
                     }
                 }
             }
             finally
             {
                 (enumerator as IDisposable)?.Dispose();
             }
         }
     }
     finally
     {
         m_appenderLock.ReleaseWriterLock();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Collect the appenders from an <see cref="T:log4net.Core.IAppenderAttachable" /> container
 /// </summary>
 /// <param name="appenderList"></param>
 /// <param name="container"></param>
 private static void CollectAppenders(ArrayList appenderList, IAppenderAttachable container)
 {
     AppenderCollection.IAppenderCollectionEnumerator enumerator = container.Appenders.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             IAppender current = enumerator.Current;
             CollectAppender(appenderList, current);
         }
     }
     finally
     {
         (enumerator as IDisposable)?.Dispose();
     }
 }
 /// <summary>
 /// Gets an attached appender with the specified name.
 /// </summary>
 /// <param name="name">The name of the appender to get.</param>
 /// <returns>
 /// The appender with the name specified, or <c>null</c> if no appender with the
 /// specified name is found.
 /// </returns>
 /// <remarks>
 /// <para>
 /// Lookup an attached appender by name.
 /// </para>
 /// </remarks>
 public IAppender GetAppender(string name)
 {
     if (m_appenderList != null && name != null)
     {
         AppenderCollection.IAppenderCollectionEnumerator enumerator = m_appenderList.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 IAppender current = enumerator.Current;
                 if (name == current.Name)
                 {
                     return(current);
                 }
             }
         }
         finally
         {
             (enumerator as IDisposable)?.Dispose();
         }
     }
     return(null);
 }