예제 #1
0
        /// <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;
            }
        }
예제 #2
0
 private static void Perform(IAppender appender)
 {
     for (var i = 0; i < 100; i++)
     {
         appender.DoAppend(new LoggingEvent(new LoggingEventData {
             TimeStamp = DateTime.UtcNow, Message = "TEST"
         }));
     }
 }
예제 #3
0
            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);
            }
예제 #4
0
        /// <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);
            }
        }
예제 #5
0
        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);
                }
            }
        }
예제 #6
0
        /// <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);
                }
            }
        }
예제 #7
0
		/// <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);
				}
			}
		}
예제 #8
0
 /// <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);
 }