/// <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); } }
/// <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); } }
/// <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> /// 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); } } } }
/// <summary> /// Adds the log event to asynchronous queue to be processed by /// the lazy writer thread. /// </summary> /// <param name="logEvent">The log event.</param> /// <remarks> /// The <see cref="Target.PrecalculateVolatileLayouts"/> is called /// to ensure that the log event can be processed in another thread. /// </remarks> public override void Write(LogEventInfo logEvent) { WrappedTarget.PrecalculateVolatileLayouts(logEvent); RequestQueue.Enqueue(logEvent); }