Esempio n. 1
0
        public static List <FormattedTraceListenerBase> GetListeners(LogListenerElementCollection listenerElements)
        {
            TraceListenerFactory.rwLock.AcquireWriterLock(TraceListenerFactory.DefaultLockTimeout);
            try
            {
                List <FormattedTraceListenerBase> listeners = new List <FormattedTraceListenerBase>();

                if (listenerElements != null)
                {
                    foreach (LogListenerElement listenerelement in listenerElements)
                    {
                        FormattedTraceListenerBase listener = GetListenerFromConfig(listenerelement);

                        if (listener != null)
                        {
                            listeners.Add(listener);
                        }
                    }
                }

                return(listeners);
            }
            catch (Exception ex)
            {
                throw new LogException("创建Listeners时发生错误:" + ex.Message, ex);
            }
            finally
            {
                TraceListenerFactory.rwLock.ReleaseWriterLock();
            }
        }
Esempio n. 2
0
        private void CreateListenerElementCollection(System.Xml.XmlReader reader)
        {
            LogListenerElementCollection logListenerElementCollection = new LogListenerElementCollection(this.Name + "~Listeners");

            logListenerElementCollection.DeserializeElementDirectly(reader, false);

            this.dicRWLock.AcquireWriterLock(1000);
            try
            {
                elementCollectionDic.Add(this.Name + "~Listeners", logListenerElementCollection);
            }
            finally
            {
                this.dicRWLock.ReleaseWriterLock();
            }
        }