NLog.Targets.Wrappers.LimitingTargetWrapper.Write C# (CSharp) Method

Write() protected method

Writes log event to the wrapped target if the current MessagesWrittenCount is lower than MessageLimit. If the MessageLimit is already reached, no log event will be written to the wrapped target. MessagesWrittenCount resets when the current Interval is expired.
protected Write ( NLog.Common.AsyncLogEventInfo logEvent ) : void
logEvent NLog.Common.AsyncLogEventInfo Log event to be written out.
return void
        protected override void Write(AsyncLogEventInfo logEvent)
        {
            if (IsIntervalExpired())
            {
                ResetInterval();
                InternalLogger.Debug("LimitingWrapper '{0}': new interval of '{1}' started.", Name, Interval);
            }

            if (MessagesWrittenCount < MessageLimit)
            {
                this.WrappedTarget.WriteAsyncLogEvent(logEvent);
                MessagesWrittenCount++;
            }
            else
            {
                logEvent.Continuation(null);
                InternalLogger.Trace("LimitingWrapper '{0}': discarded event, because MessageLimit of '{1}' was reached.", Name, MessageLimit);
            }
        }