Exemple #1
0
        /// <summary>
        ///     Flushes pending events in the buffer (if any).
        /// </summary>
        /// <param name="asyncContinuation">The asynchronous continuation.</param>
        protected override void FlushAsync(AsyncContinuation asyncContinuation)
        {
            var events = buffer.GetEventsAndClear();

            if (events.Length == 0)
            {
                WrappedTarget.Flush(asyncContinuation);
            }
            else
            {
                WrappedTarget.WriteAsyncLogEvents(events, ex => WrappedTarget.Flush(asyncContinuation));
            }
        }
Exemple #2
0
        private void ProcessPendingEvents(object state)
        {
            try
            {
                var count        = BatchSize;
                var continuation = Interlocked.Exchange(ref flushAllContinuation, null);
                if (continuation != null)
                {
                    count = RequestQueue.RequestCount;
                    InternalLogger.Trace("Flushing {0} events.", count);
                }

                var logEventInfos = RequestQueue.DequeueBatch(count);

                if (continuation != null)
                {
                    // write all events, then flush, then call the continuation
                    WrappedTarget.WriteAsyncLogEvents(logEventInfos, ex => WrappedTarget.Flush(continuation));
                }
                else
                {
                    // just write all events
                    WrappedTarget.WriteAsyncLogEvents(logEventInfos);
                }
            }
            catch (Exception exception)
            {
                if (exception.MustBeRethrown())
                {
                    throw;
                }

                InternalLogger.Error("Error in lazy writer timer procedure: {0}", exception);
            }
            finally
            {
                StartLazyWriterTimer();
            }
        }
 /// <summary>
 /// Forwards the call to the <see cref="WrapperTargetBase.WrappedTarget"/>.Write()
 /// and calls <see cref="Target.Flush()"/> on it.
 /// </summary>
 /// <param name="logEvent"></param>
 protected internal override void Write(LogEventInfo logEvent)
 {
     WrappedTarget.Write(logEvent);
     WrappedTarget.Flush();
 }
Exemple #4
0
        /// <summary>
        /// Schedules a flush operation, that triggers when all pending flush operations are completed (in case of asynchronous targets).
        /// </summary>
        /// <param name="asyncContinuation">The asynchronous continuation.</param>
        protected override void FlushAsync(AsyncContinuation asyncContinuation)
        {
            var wrappedContinuation = _pendingManualFlushList.RegisterCompletionNotification(asyncContinuation);

            WrappedTarget.Flush(wrappedContinuation);
        }
 /// <summary>
 /// Flush any pending log messages (in case of asynchronous targets).
 /// </summary>
 /// <param name="asyncContinuation">The asynchronous continuation.</param>
 protected override void FlushAsync(AsyncContinuation asyncContinuation)
 {
     RunImpersonated(_newIdentity, (s) => WrappedTarget.Flush(s), asyncContinuation);
 }
 /// <summary>
 /// Forwards the call to the <see cref="WrapperTargetBase.WrappedTarget"/>.Write()
 /// and calls <see cref="Target.Flush()"/> on it.
 /// </summary>
 /// <param name="logEvent"></param>
 public override void Write(LogEventInfo logEvent)
 {
     WrappedTarget.Write(logEvent);
     WrappedTarget.Flush();
 }