Ejemplo n.º 1
0
        /// <summary>
        /// Creates an instance of the <see cref="AsyncBufferingForwardingAppender"/>
        /// </summary>
        public AsyncBufferingForwardingAppender()
        {
            _sequencer              = new Sequencer <Action>(action => action());
            _sequencer.OnException += (sender, args) => LogLog.Error(GetType(), "An exception occurred while processing LogEvents.", args.Exception);

            _idleTimeThreshold = TimeSpan.FromMilliseconds(500);
            _idleFlushTimer    = new Timer(state => _sequencer.TryEnqueue(InvokeFlushIfIdle), null, _idleTimeThreshold, _idleTimeThreshold);
        }
        /// <summary>
        /// Activates the options for this appender.
        /// </summary>
        public override void ActivateOptions()
        {
            base.ActivateOptions();

            if (IdleTime <= 0)
            {
                IdleTime = DEFAULT_IDLE_TIME;
            }

            _idleTimeThreshold = TimeSpan.FromMilliseconds(IdleTime);
            _idleFlushTimer    = new Timer(state => _sequencer.TryEnqueue(InvokeFlushIfIdle), null, _idleTimeThreshold, _idleTimeThreshold);

            LogWarningIfLossy();
        }