示例#1
0
        /// <summary>
        /// Adds the specified log event to the buffer and flushes
        /// the buffer in case the buffer gets full.
        /// </summary>
        /// <param name="logEvent">The log event.</param>
        protected override void Write(AsyncLogEventInfo logEvent)
        {
            PrecalculateVolatileLayouts(logEvent.LogEvent);

            int count = _buffer.Append(logEvent);

            if (count >= BufferSize)
            {
                // If the OverflowAction action is set to "Discard", the buffer will automatically
                // roll over the oldest item.
                if (OverflowAction == BufferingTargetWrapperOverflowAction.Flush)
                {
                    WriteEventsInBuffer("Exceeding BufferSize");
                }
            }
            else
            {
                if (FlushTimeout > 0)
                {
                    // reset the timer on first item added to the buffer or whenever SlidingTimeout is set to true
                    if (SlidingTimeout || count == 1)
                    {
                        _flushTimer.Change(FlushTimeout, -1);
                    }
                }
            }
        }
        /// <summary>
        /// Adds the specified log event to the buffer.
        /// </summary>
        /// <param name="logEvent">The log event.</param>
        public override void Write(LogEventInfo logEvent)
        {
            WrappedTarget.PrecalculateVolatileLayouts(logEvent);
            LogEventInfoBuffer buffer = GetRequestBuffer();

            if (buffer != null)
            {
                buffer.Append(logEvent);
            }
        }
示例#3
0
        /// <summary>
        /// Adds the specified log event to the buffer.
        /// </summary>
        /// <param name="logEvent">The log event.</param>
        protected override void Write(AsyncLogEventInfo logEvent)
        {
            LogEventInfoBuffer buffer = GetRequestBuffer();

            if (buffer != null)
            {
                WrappedTarget.PrecalculateVolatileLayouts(logEvent.LogEvent);

                buffer.Append(logEvent);
                InternalLogger.Trace("Appending log event {0} to ASP.NET request buffer.", logEvent.LogEvent.SequenceID);
            }
            else
            {
                InternalLogger.Trace("ASP.NET request buffer does not exist. Passing to wrapped target.");
                WrappedTarget.WriteAsyncLogEvent(logEvent);
            }
        }
示例#4
0
 /// <summary>
 /// Adds the specified log event to the buffer and flushes
 /// the buffer in case the buffer gets full.
 /// </summary>
 /// <param name="logEvent">The log event.</param>
 public override void Write(LogEventInfo logEvent)
 {
     lock (this)
     {
         WrappedTarget.PrecalculateVolatileLayouts(logEvent);
         int count = _buffer.Append(logEvent);
         if (count >= BufferSize)
         {
             LogEventInfo[] events = _buffer.GetEventsAndClear();
             WrappedTarget.Write(events);
         }
         else
         {
             if (FlushTimeout > 0 && _flushTimer != null)
             {
                 _flushTimer.Change(FlushTimeout, -1);
             }
         }
     }
 }
        /// <summary>
        /// Writes an array of logging events to the log target. By default it iterates on all
        /// events and passes them to "Append" method. Inheriting classes can use this method to
        /// optimize batch writes.
        /// </summary>
        /// <param name="logEvents">Logging events to be written out.</param>
        protected override void Write(IList<AsyncLogEventInfo> logEvents)
        {
            // if web service call is being processed, buffer new events and return
            // lock is being held here
            if (inCall)
            {
                for (int i = 0; i < logEvents.Count; ++i)
                {
                    PrecalculateVolatileLayouts(logEvents[i].LogEvent);
                    buffer.Append(logEvents[i]);
                }
                return;
            }

            // OptimizeBufferReuse = true, will reuse the input-array on method-exit (so we make clone here)
            AsyncLogEventInfo[] logEventsArray = new AsyncLogEventInfo[logEvents.Count];
            logEvents.CopyTo(logEventsArray, 0);

            var networkLogEvents = TranslateLogEvents(logEventsArray);
            Send(networkLogEvents, logEventsArray, null);
        }
示例#6
0
        /// <summary>
        ///     Adds the specified log event to the buffer and flushes
        ///     the buffer in case the buffer gets full.
        /// </summary>
        /// <param name="logEvent">The log event.</param>
        protected override void Write(AsyncLogEventInfo logEvent)
        {
            WrappedTarget.PrecalculateVolatileLayouts(logEvent.LogEvent);

            var count = buffer.Append(logEvent);

            if (count >= BufferSize)
            {
                var events = buffer.GetEventsAndClear();
                WrappedTarget.WriteAsyncLogEvents(events);
            }
            else
            {
                if (FlushTimeout > 0)
                {
                    // reset the timer on first item added to the buffer or whenever SlidingTimeout is set to true
                    if (SlidingTimeout || count == 1)
                    {
                        flushTimer.Change(FlushTimeout, -1);
                    }
                }
            }
        }