本文整理汇总了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();
}
}
示例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
}
示例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;
}
示例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();
}
}
示例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));
}
示例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))
{
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
}