private static bool HasCountingAppender(IAppenderAttachable logger)
 {
     foreach (IAppender appender in logger.Appenders)
     {
         if (appender is CountToContextItemsAppender)
             return true;
     }
     return false;
 }
        public Log4NetInMemoryStreamAppenderManager()
        {
            _loggerRoot = ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root;

            _memoryAppender = new MemoryAppender
                                  {
                                      Threshold = Level.All,
                                      Name = this.GetType().Name,
                                      Layout = new PatternLayout("{message}")
                                  };

            if (_loggerRoot != null)
                _loggerRoot.AddAppender(_memoryAppender);
        }
Ejemplo n.º 3
0
        protected virtual void AddAppender(IAppender profilerAppender, IAppenderAttachable logger)
        {
            IAppender appender;
            do {
                appender = logger.GetAppender(profilerAppender.Name);
                if (appender != null) {
                    try {
                        logger.RemoveAppender(appender);
                    }
                    catch (Exception) { }
                }
            }
            while (appender != null);

            logger.AddAppender(profilerAppender);
        }
Ejemplo n.º 4
0
        private void CreateAppenderForLogger(string csvHeader, string fileName, IAppenderAttachable myLogger)
        {
            var appender = new RollingFileAppender
            {
                File = fileName,
                AppendToFile = true,
                Layout = new PatternLayout("%message%newline")
                {
                    Header = csvHeader + Environment.NewLine
                },
                MaxFileSize = maxFileSize,
                MaxSizeRollBackups = rollBackups,
                RollingStyle = RollingFileAppender.RollingMode.Size
            };

            appender.ActivateOptions();
            myLogger.AddAppender(appender);
            BasicConfigurator.Configure(appender);
        }
		private static void CheckAppenders(IAppenderAttachable logger, string accountName, string profileName)
		{
			logger.Appenders.Should(Be.Not.Empty);
			logger.Appenders.OfType<PluginRollingFileAppender>().Should(Be.Not.Empty);

			var appender = logger.Appenders.OfType<PluginRollingFileAppender>().First();
			appender.File.Contains(accountName).Should(Be.True);
			appender.File.Contains(profileName).Should(Be.True);
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Collect the appenders from an <see cref="IAppenderAttachable"/> container
		/// </summary>
		/// <param name="appenderList"></param>
		/// <param name="container"></param>
		private static void CollectAppenders(System.Collections.ArrayList appenderList, IAppenderAttachable container)
		{
			foreach(log4net.Appender.IAppender appender in container.Appenders)
			{
				CollectAppender(appenderList, appender);
			}
		}
Ejemplo n.º 7
0
 private static bool HasQueryAppender(IAppenderAttachable logger)
 {
     foreach (IAppender appender in logger.Appenders)
     {
         if (appender is QueryAppender)
             return true;
     }
     return false;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Collect the appenders from an <see cref="IAppenderAttachable"/> container
 /// </summary>
 /// <param name="appenderList"></param>
 /// <param name="container"></param>
 static void CollectAppenders(ArrayList appenderList, IAppenderAttachable container) {
   foreach (IAppender appender in container.Appenders)
     CollectAppender(appenderList, appender);
 }