/// <summary> /// Sets the <see cref="IAppender"/>'s filter level to the level specified /// </summary> /// <param name="appender">the <see cref="IAppender"/> to change</param> /// <param name="newLevel">the new level at which the <see cref="IAppender"/> should log</param> private static void SetAppenderFilterLevel(IAppender appender, log4net.Core.Level newLevel) { if (appender == null || newLevel == null) { return; } AppenderSkeleton baseAppender = appender as AppenderSkeleton; if (baseAppender == null) { return; } log4net.Filter.LevelRangeFilter rangeFilter = GetLevelRangeFilter(baseAppender); if (rangeFilter == null) { return; } // lock the IAppender so that its clients wait until this process completes lock (baseAppender) { appender.DoAppend(new log4net.Core.LoggingEvent(logger.GetType(), log4net.LogManager.GetRepository(), logger.GetType().Name, log4net.Core.Level.Info, "Changed log level to " + newLevel.ToString(), null)); rangeFilter.LevelMin = newLevel; } }
private static void Perform(IAppender appender) { for (var i = 0; i < 100; i++) { appender.DoAppend(new LoggingEvent(new LoggingEventData { TimeStamp = DateTime.UtcNow, Message = "TEST" })); } }
private static TimeSpan Perform(IAppender appender) { var stopwatch = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { appender.DoAppend(new LoggingEvent(new LoggingEventData { TimeStamp = DateTime.UtcNow, Message = "TEST" })); } stopwatch.Stop(); return(stopwatch.Elapsed); }
/// <summary> /// Calls the DoAppende method on the <see cref="T:log4net.Appender.IAppender" /> with /// the <see cref="T:log4net.Core.LoggingEvent" /> objects supplied. /// </summary> /// <param name="appender">The appender</param> /// <param name="loggingEvents">The events</param> /// <remarks> /// <para> /// If the <paramref name="appender" /> supports the <see cref="T:log4net.Appender.IBulkAppender" /> /// interface then the <paramref name="loggingEvents" /> will be passed /// through using that interface. Otherwise the <see cref="T:log4net.Core.LoggingEvent" /> /// objects in the array will be passed one at a time. /// </para> /// </remarks> private static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents) { IBulkAppender bulkAppender = appender as IBulkAppender; if (bulkAppender != null) { bulkAppender.DoAppend(loggingEvents); return; } foreach (LoggingEvent loggingEvent in loggingEvents) { appender.DoAppend(loggingEvent); } }
private static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents) { IBulkAppender appender2 = appender as IBulkAppender; if (appender2 != null) { appender2.DoAppend(loggingEvents); } else { foreach (LoggingEvent event2 in loggingEvents) { appender.DoAppend(event2); } } }
/// <summary> /// Calls the DoAppende method on the <see cref="IAppender"/> with /// the <see cref="LoggingEvent"/> objects supplied. /// </summary> /// <param name="appender">The appender</param> /// <param name="loggingEvents">The events</param> /// <remarks> /// <para> /// If the <paramref name="appender" /> supports the <see cref="IBulkAppender"/> /// interface then the <paramref name="loggingEvents" /> will be passed /// through using that interface. Otherwise the <see cref="LoggingEvent"/> /// objects in the array will be passed one at a time. /// </para> /// </remarks> static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents) { var bulkAppender = appender as IBulkAppender; if (bulkAppender != null) { bulkAppender.DoAppend(loggingEvents); } else { foreach (LoggingEvent loggingEvent in loggingEvents) { appender.DoAppend(loggingEvent); } } }
/// <summary> /// Calls the DoAppende method on the <see cref="IAppender"/> with /// the <see cref="LoggingEvent"/> objects supplied. /// </summary> /// <param name="appender">The appender</param> /// <param name="loggingEvents">The events</param> /// <remarks> /// <para> /// If the <paramref name="appender" /> supports the <see cref="IBulkAppender"/> /// interface then the <paramref name="loggingEvents" /> will be passed /// through using that interface. Otherwise the <see cref="LoggingEvent"/> /// objects in the array will be passed one at a time. /// </para> /// </remarks> private static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents) { IBulkAppender bulkAppender = appender as IBulkAppender; if (bulkAppender != null) { bulkAppender.DoAppend(loggingEvents); } else { foreach(LoggingEvent loggingEvent in loggingEvents) { appender.DoAppend(loggingEvent); } } }
/// <summary> /// Calls the DoAppende method on the <see cref="IAppender"/> with /// the <see cref="LoggingEvent"/> objects supplied. /// </summary> /// <param name="appender">The appender</param> /// <param name="loggingEvents">The events</param> /// <remarks> /// <para> /// If the <paramref name="appender" /> supports the <see cref="IBulkAppender"/> /// interface then the <paramref name="loggingEvents" /> will be passed /// through using that interface. Otherwise the <see cref="LoggingEvent"/> /// objects in the array will be passed one at a time. /// </para> /// </remarks> static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents) { var bulkAppender = appender as IBulkAppender; if (bulkAppender != null) bulkAppender.DoAppend(loggingEvents); else foreach (LoggingEvent loggingEvent in loggingEvents) appender.DoAppend(loggingEvent); }