当前位置: 首页>>代码示例>>C#>>正文


C# ConsoleAppender.AddFilter方法代码示例

本文整理汇总了C#中log4net.Appender.ConsoleAppender.AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleAppender.AddFilter方法的具体用法?C# ConsoleAppender.AddFilter怎么用?C# ConsoleAppender.AddFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log4net.Appender.ConsoleAppender的用法示例。


在下文中一共展示了ConsoleAppender.AddFilter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureLog4Net

 private static void ConfigureLog4Net()
 {
     if (ConfigurationManager.GetSection("log4net") == null)
     {
         var layout = new SimpleLayout();
         layout.ActivateOptions();
         var consoleAppender = new ConsoleAppender
                                   {
                                       Layout = layout
                                   };
         consoleAppender.AddFilter(new LevelRangeFilter
                                       {
                                           LevelMin = Level.Info,
                                           LevelMax = Level.Fatal,
                                           AcceptOnMatch = false
                                       });
         consoleAppender.AddFilter(
             new LoggerMatchFilter
                 {
                     LoggerToMatch = "Remora",
                     AcceptOnMatch = true
                 }
             );
         consoleAppender.AddFilter(new DenyAllFilter());
         consoleAppender.ActivateOptions();
         BasicConfigurator.Configure(consoleAppender);
     }
     else
     {
         XmlConfigurator.Configure();
     }
 }
开发者ID:julienblin,项目名称:Remora,代码行数:32,代码来源:Program.cs

示例2: Log4NetFiltering

        public Log4NetFiltering()
        {
            #region Log4NetFilterUsage

            ConsoleAppender appender = new ConsoleAppender
            {
                Threshold = Level.Debug,
                Layout = new SimpleLayout(),
            };

            appender.AddFilter(new NServiceBusLogFilter());
            appender.ActivateOptions();

            BasicConfigurator.Configure(appender);

            NServiceBus.Logging.LogManager.Use<Log4NetFactory>();

            #endregion
        }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:19,代码来源:Log4NetFiltering.cs

示例3: SetupLogger

 private void SetupLogger()
 {
     Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
     PatternLayout patternLayout = new PatternLayout();
     patternLayout.ConversionPattern = "%date [%thread] %-5level [%class.%method] - %message%newline";
     patternLayout.ActivateOptions();
     RollingFileAppender roller = new RollingFileAppender();
     roller.AppendToFile = false;
     roller.File = @"ResultExporterLog.txt";
     roller.Layout = patternLayout;
     roller.MaxSizeRollBackups = 5;
     roller.MaximumFileSize = "1GB";
     roller.RollingStyle = RollingFileAppender.RollingMode.Size;
     roller.StaticLogFileName = true;
     roller.ActivateOptions();
     ConsoleAppender console = new ConsoleAppender();
     PatternLayout consolePatternLayout = new PatternLayout();
     consolePatternLayout.ConversionPattern = "%date [Testlink Result Exporter] [%level] %message%newline";
     consolePatternLayout.ActivateOptions();
     LevelRangeFilter consoleLevelFilter = new LevelRangeFilter();
     consoleLevelFilter.LevelMin = Level.Info;
     consoleLevelFilter.LevelMax = Level.Fatal;
     console.AddFilter(consoleLevelFilter);
     console.Layout = consolePatternLayout;
     hierarchy.Root.AddAppender(roller);
     hierarchy.Root.AddAppender(console);
     hierarchy.Root.Level = Level.All;
     hierarchy.Configured = true;
 }
开发者ID:christianeisendle,项目名称:nunit-testlink-adapter,代码行数:29,代码来源:ResultExporter.cs

示例4: Main

		static void Main()
		{
			var consoleAppender = new ConsoleAppender
			{
				Layout = new SimpleLayout(),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = "Raven.Client"
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);

			// start 5 instances of Raven's servers
			Console.WriteLine("Starting...");
			DeleteDirectories("Users", "Blogs", "Posts.1", "Posts.2", "Posts.3");
			var ravenDbServers = StartServers();
			Console.WriteLine("All servers started...");

			var shards = new Shards
			{
				new DocumentStore
				{
					Identifier = "Users",
					Url = "http://localhost:8081",
					Conventions =
						{
							DocumentKeyGenerator = user => "users/" + ((User) user).Name
						}
				},
				new DocumentStore {Identifier = "Blogs", Url = "http://localhost:8082"},
				new DocumentStore {Identifier = "Posts #1", Url = "http://localhost:8083"},
				new DocumentStore {Identifier = "Posts #2", Url = "http://localhost:8084"},
				new DocumentStore {Identifier = "Posts #3", Url = "http://localhost:8085"}
			};

			var shardStrategy = new ShardStrategy
			{
				ShardAccessStrategy =new ParallelShardAccessStrategy(),
				ShardSelectionStrategy = new BlogShardSelectionStrategy(3),
				ShardResolutionStrategy = new BlogShardResolutionStrategy(3),
			};
			var documentStore = new ShardedDocumentStore(shardStrategy, shards);
			documentStore.Initialize();

			using(var session = documentStore.OpenSession())
			{
				var user = new User { Name = "ayende" };
				var blog = new Blog { Name = "Ayende @ Rahien" };

				session.Store(user);
				session.Store(blog);

				// we have to save to Raven to get the generated id for the blog instance
				session.SaveChanges();
				var posts = new List<Post>();
				for (var i = 0; i < 6; i++)
				{
					var post = new Post
					{
						BlogId = blog.Id,
						UserId = user.Id,
						Content = "Just a post",
						Title = "Post #" + (i + 1)
					};
					posts.Add(post);
					session.Store(post);
				}

				session.SaveChanges();
			}

			// queries
			using (var session = documentStore.OpenSession())
			{
				session.LuceneQuery<User>().WaitForNonStaleResults().ToArray();
				session.LuceneQuery<Blog>().WaitForNonStaleResults().ToArray();
				session.LuceneQuery<Post>().WaitForNonStaleResults().ToArray();
			}

			// loading
			using (var session = documentStore.OpenSession())
			{
				session.Load<User>("users/ayende");
				session.Load<Blog>("blogs/1");
				session.Load<Post>("posts/1/2");
				session.Load<Post>("posts/2/2");
			}

			documentStore.Dispose();

			foreach (var server in ravenDbServers)
			{
				server.Dispose();
			}
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:97,代码来源:Program.cs

示例5: ConfigureLog

        ILog ConfigureLog()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.RemoveAllAppenders();

            PatternLayout patternLayout = new PatternLayout();
            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            ConsoleAppender consoleErrAppender = new ConsoleAppender();
            consoleErrAppender.Layout = patternLayout;
            consoleErrAppender.ActivateOptions();
            consoleErrAppender.Target = "Console.Error";
            log4net.Filter.LevelRangeFilter errfilter = new log4net.Filter.LevelRangeFilter();
            errfilter.LevelMin = Level.Verbose;
            errfilter.LevelMax = Level.Emergency;
            consoleErrAppender.AddFilter(errfilter);
            hierarchy.Root.AddAppender(consoleErrAppender);

            hierarchy.Root.Level = Level.Info;
            if (verbose == true)
            {
                hierarchy.Root.Level = Level.Debug;
            }
            hierarchy.Configured = true;

            BasicConfigurator.Configure(new ConsoleAppender[] { consoleErrAppender });

            return LogManager.GetLogger(typeof(OpenSearchClient));
        }
开发者ID:Terradue,项目名称:DotNetOpenSearchClient,代码行数:30,代码来源:OpenSearchClient.cs

示例6: RunInDebugMode

        private static void RunInDebugMode(AnonymousUserAccessMode? anonymousUserAccessMode, RavenConfiguration ravenConfiguration)
        {
			var consoleAppender = new ConsoleAppender
			{
				Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = typeof(HttpServer).FullName
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            while (RunServer(ravenConfiguration))
            {
                
            }
        }
开发者ID:plasmaboyer,项目名称:ravendb,代码行数:21,代码来源:Program.cs

示例7: RunInDebugMode

        private static void RunInDebugMode(AnonymousUserAccessMode? anonymousUserAccessMode)
        {
			var consoleAppender = new ConsoleAppender
			{
				Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
			};
			consoleAppender.AddFilter(new LoggerMatchFilter
			{
				AcceptOnMatch = true,
				LoggerToMatch = typeof(HttpServer).FullName
			});
			consoleAppender.AddFilter(new DenyAllFilter());
			BasicConfigurator.Configure(consoleAppender);
            var ravenConfiguration = new RavenConfiguration();
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            using (new RavenDbServer(ravenConfiguration))
            {
                var path = Path.Combine(Environment.CurrentDirectory, "default.raven");
                if (File.Exists(path))
                {
                    Console.WriteLine("Loading data from: {0}", path);
                    Smuggler.Smuggler.ImportData(ravenConfiguration.ServerUrl, path);
                }

                Console.WriteLine("Raven is ready to process requests.");
                Console.WriteLine("Data directory: {0}, Port: {1}", ravenConfiguration.DataDirectory, ravenConfiguration.Port);
                Console.WriteLine("Press the enter key to stop the server or enter 'cls' and then enter to clear the log");
                while (true)
                {
                    var readLine = Console.ReadLine();
                    if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
                        break;
                    Console.Clear();
                }
            }
        }
开发者ID:Inferis,项目名称:ravendb,代码行数:38,代码来源:Program.cs

示例8: BootstrapLogger

		static void BootstrapLogger()
		{
            Logger.UseLogger(new Log4NetLogger());

			_appender = new ConsoleAppender();
			_appender.Threshold = Level.Info;
			_appender.Layout = new PatternLayout("%m%n");

			var filter = new LoggerMatchFilter();
			filter.AcceptOnMatch = false;
			filter.LoggerToMatch = "MassTransit";

			_appender.AddFilter(filter);


			BasicConfigurator.Configure(_appender);
		}
开发者ID:cstick,项目名称:MassTransit,代码行数:17,代码来源:Program.cs

示例9: RunInDebugMode

 private static void RunInDebugMode(bool createDefaultDatabase, AnonymousUserAccessMode? anonymousUserAccessMode)
 {
     var consoleAppender = new ConsoleAppender
     {
         Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
     };
     consoleAppender.AddFilter(new LoggerMatchFilter
     {
         AcceptOnMatch = true,
         LoggerToMatch = typeof (HttpServer).FullName
     });
     BasicConfigurator.Configure(consoleAppender);
     var ravenConfiguration = new RavenConfiguration
     {
         ShouldCreateDefaultsWhenBuildingNewDatabaseFromScratch = createDefaultDatabase,
     };
     RavenDbServer.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
     if (anonymousUserAccessMode.HasValue)
         ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
     using (new RavenDbServer(ravenConfiguration))
     {
         Console.WriteLine("Raven is ready to process requests.");
         Console.WriteLine("Press any key to stop the server");
         Console.ReadLine();
     }
 }
开发者ID:torkelo,项目名称:ravendb,代码行数:26,代码来源:Program.cs

示例10: RunInDebugMode

        private static void RunInDebugMode(Raven.Http.AnonymousUserAccessMode? anonymousUserAccessMode, RavenConfiguration ravenConfiguration)
        {
            var consoleAppender = new ConsoleAppender
            {
                Layout = new PatternLayout(PatternLayout.DefaultConversionPattern),
            };
            consoleAppender.AddFilter(new LoggerMatchFilter
            {
                AcceptOnMatch = true,
                LoggerToMatch = typeof(HttpServer).FullName
            });
            consoleAppender.AddFilter(new DenyAllFilter());
            BasicConfigurator.Configure(consoleAppender);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(ravenConfiguration.Port);
            if (anonymousUserAccessMode.HasValue)
                ravenConfiguration.AnonymousUserAccessMode = anonymousUserAccessMode.Value;
            using (new RavenMqServer(ravenConfiguration))
            {

                Console.WriteLine("RavenMQ is ready to process requests. Build {0}, Version {1}", Queues.BuildVersion, Queues.ProductVersion);
                Console.WriteLine("Data directory: {0}", ravenConfiguration.DataDirectory);
                Console.WriteLine("HostName: {0} Port: {1}, Storage: Munin", ravenConfiguration.HostName ?? "<any>",
                    ravenConfiguration.Port);
                Console.WriteLine("Server Url: {0}", ravenConfiguration.ServerUrl);
                Console.WriteLine("Press <enter> to stop or 'cls' and <enter> to clear the log");
                while (true)
                {
                    var readLine = Console.ReadLine();
                    if (!"CLS".Equals(readLine, StringComparison.InvariantCultureIgnoreCase))
                        break;
                    Console.Clear();
                }
            }
        }
开发者ID:nieve,项目名称:ravenmq,代码行数:34,代码来源:Program.cs


注:本文中的log4net.Appender.ConsoleAppender.AddFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。