コード例 #1
0
        override public void ActivateOptions()
        {
            base.ActivateOptions();

            // If the appender is in Lossy mode then we will
            // only send the buffer when the Evaluator triggers
            // therefore check we have an evaluator.
            if (m_lossy && m_evaluator == null)
            {
                ErrorHandler.Error("Appender [" + Name + "] is Lossy but has no Evaluator. The buffer will never be sent!");
            }

            if (m_bufferSize > 1)
            {
                m_cb = new CyclicBuffer(m_bufferSize);
            }
            else
            {
                m_cb = null;
            }
        }
コード例 #2
0
        /// <summary>
        /// 发送缓冲区里的日志消息给所有 Apeender
        /// </summary>
        /// <param name="firstLoggingEvent">原来在缓冲器中被挤出来的最古老的消息</param>
        /// <param name="buffer">缓冲区的日志消息</param>
        virtual protected void SendFromBuffer(LoggingEvent firstLoggingEvent, CyclicBuffer buffer)
        {
            LoggingEvent[] bufferEvents = buffer.PopAll();

            if (firstLoggingEvent == null)
            {
                SendBuffer(bufferEvents);
            }
            else if (bufferEvents.Length == 0)
            {
                SendBuffer(new LoggingEvent[] { firstLoggingEvent });
            }
            else
            {
                // Create new array with the firstLoggingEvent at the head
                LoggingEvent[] events = new LoggingEvent[bufferEvents.Length + 1];
                Array.Copy(bufferEvents, 0, events, 1, bufferEvents.Length);
                events[0] = firstLoggingEvent;

                SendBuffer(events);
            }
        }