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


C# ConsoleAppender.ActivateOptions方法代码示例

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


在下文中一共展示了ConsoleAppender.ActivateOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Configure

        public void Configure()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.RemoveAllAppenders(); /*Remove any other appenders*/

            FileAppender fileAppender = new FileAppender();
            fileAppender.AppendToFile = true;
            fileAppender.LockingModel = new FileAppender.MinimalLock();
            fileAppender.File = _locationProvider.GetFilePath();
            PatternLayout pl = new PatternLayout();
            pl.ConversionPattern = "%d [%2%t] %-5p [%-10c]   %m%n%n";
            pl.ActivateOptions();
            fileAppender.Layout = pl;
            fileAppender.ActivateOptions();

            ConsoleAppender consoleAppender = new ConsoleAppender();
            consoleAppender.Layout = pl;
            consoleAppender.ActivateOptions();

            //            log4net.Config.BasicConfigurator.Configure(fileAppender);
            IAppender[] appenders = {fileAppender, consoleAppender};
            log4net.Config.BasicConfigurator.Configure(appenders);
            var log = LogManager.GetLogger(GetType());
            log.Debug("Logging Configured");
        }
开发者ID:SimplyChris,项目名称:LibHipChat,代码行数:25,代码来源:LogConfigurator.cs

示例3: Configure

        public static void Configure()
        {
            var hierarchy = (Hierarchy)LogManager.GetRepository();
            hierarchy.Root.RemoveAllAppenders();

            // see http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html

            var layout = new PatternLayout
            {
                ConversionPattern = "%date{dd-MMM-yyyy HH:mm:ss}  %-5level  %message%n%exception%n"
            };

            var fileAppender = new RollingFileAppender
            {
                Layout = layout,
                AppendToFile = true,
                File = "log.txt",
                LockingModel = new FileAppender.MinimalLock(),
            };

            var consoleAppender = new ConsoleAppender
            {
                Layout = layout,
            };

            layout.ActivateOptions();

            fileAppender.ActivateOptions();
            log4net.Config.BasicConfigurator.Configure(fileAppender);

            consoleAppender.ActivateOptions();
            log4net.Config.BasicConfigurator.Configure(consoleAppender);
        }
开发者ID:sumothecat,项目名称:Pushbaby,代码行数:33,代码来源:Log4NetConfiguration.cs

示例4: Setup

        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

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

            RollingFileAppender roller = new RollingFileAppender();
            roller.AppendToFile = false;
            roller.File = @"Logs\EventLog.txt";
            roller.Layout = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize = "1GB";
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            ConsoleAppender appender = new ConsoleAppender();
            appender.Layout = patternLayout;
            appender.ActivateOptions();
            hierarchy.Root.AddAppender(appender);

            MemoryAppender memory = new MemoryAppender();
            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Debug;
            hierarchy.Configured = true;
        }
开发者ID:nmpountou,项目名称:Project154,代码行数:31,代码来源:Logger.cs

示例5: Configure

    /// <summary>
    /// Configures the <see cref="FileLogger"/> logger adding the appenders
    /// to the root repository.
    /// </summary>
    public void Configure() {
      // create a new logger into the repository of the current assembly.
      ILoggerRepository root_repository =
        LogManager.GetRepository(Assembly.GetExecutingAssembly());

      Logger nohros_console_logger =
        root_repository.GetLogger("NohrosConsoleLogger") as Logger;

      // create the layout and appender for on error messages.
      PatternLayout layout = new PatternLayout();
      layout.ConversionPattern = layout_pattern_;
      layout.ActivateOptions();

      // create the appender
      ConsoleAppender appender = new ConsoleAppender();
      appender.Name = "NohrosCommonConsoleAppender";
      appender.Layout = layout;
      appender.Target = "Console.Out";
      appender.Threshold = Level.All;
      appender.ActivateOptions();

      nohros_console_logger.Parent.AddAppender(appender);

      root_repository.Configured = true;

      logger = LogManager.GetLogger("NohrosConsoleLogger");
    }
开发者ID:joethinh,项目名称:nohros-must,代码行数:31,代码来源:ConsoleLogger.cs

示例6: ConfigureLogging

        static void ConfigureLogging(ServerOptions options)
        {
            var layout = new PatternLayout("%date %level - %message%newline");
            layout.ActivateOptions();

            var appenders = new List<IAppender>();
            if (!string.IsNullOrEmpty(options.LogFileDirectory))
            {
                var fileAppender = new FileAppender
                {
                    Layout = layout,
                    Encoding = Encoding.UTF8,
                    File = Path.Combine(options.LogFileDirectory, "orchestrion.log"),
                    AppendToFile = true,
                    LockingModel = new FileAppender.MinimalLock(),
                    ImmediateFlush = true,

                };
                fileAppender.ActivateOptions();
                appenders.Add(fileAppender);
            }

            if (options.ConsoleOutput)
            {
                var consoleAppender = new ConsoleAppender
                {
                    Layout = layout
                };
                consoleAppender.ActivateOptions();
                appenders.Add(consoleAppender);
            }

            BasicConfigurator.Configure(appenders.ToArray());
        }
开发者ID:navaneeth,项目名称:orchestrion,代码行数:34,代码来源:Main.cs

示例7: BindConsole

		public static void BindConsole(PatternLayout layout = null, Level level = null)
		{
			layout = layout ?? new PatternLayout
			{
				ConversionPattern = "%date{ISO8601} %level %logger - %message%newline"
			};

			layout.ActivateOptions();

			var consoleAppender = new ConsoleAppender
			{
				Name = "console",
				Layout = layout
			};

			consoleAppender.ActivateOptions();

			var hierarchy = (Hierarchy)LogManager.GetRepository();

			if (hierarchy.Root.GetAppender("console") != null)
			{
				return;
			}

			hierarchy.Root.AddAppender(consoleAppender);
			hierarchy.Root.Level = level ?? Level.Info;

			hierarchy.Configured = true;
		}
开发者ID:seyyedi,项目名称:core,代码行数:29,代码来源:LogExtensions.cs

示例8: Setup

        public static void Setup(string path)
        {
            // "%d[%2%t] %-5p[%-10c] %m %n"
            var pl = new PatternLayout {ConversionPattern = "%c%m%n"};
            pl.ActivateOptions();

            var fileAppender = new FileAppender
            {
                AppendToFile = true,
                LockingModel = new FileAppender.MinimalLock(),
                File = path,
                Layout = pl
            };
            fileAppender.ActivateOptions();

            var bufferingForwardingAppender = new BufferingForwardingAppender
            {
                Lossy = false,
                Fix = FixFlags.None
            };
            bufferingForwardingAppender.AddAppender(fileAppender);
            bufferingForwardingAppender.ActivateOptions();

            var consoleAppender = new ConsoleAppender {Layout = pl};
            consoleAppender.ActivateOptions();

            var hierarchy = (Hierarchy) LogManager.GetRepository();
            hierarchy.Root.RemoveAllAppenders();
            BasicConfigurator.Configure(hierarchy, bufferingForwardingAppender, consoleAppender);
        }
开发者ID:wwhitehead,项目名称:ProjectFaolan,代码行数:30,代码来源:Logger.cs

示例9: SetUpFixture

        public void SetUpFixture()
        {
            Util.LogLog.InternalDebugging = true;

            Hierarchy hierarchy = (Hierarchy) LogManager.GetRepository();
            PatternLayout patternLayout = new PatternLayout { ConversionPattern = "%d [%t] %-5p %m%n" };

            patternLayout.ActivateOptions();

            TraceAppender tracer = new TraceAppender { Layout = patternLayout };

            tracer.ActivateOptions();

            hierarchy.Root.AddAppender(tracer);

            ConsoleAppender console = new ConsoleAppender
                                          {
                                              Name = "console",
                                              Layout = patternLayout,
                                              Target = "Console.Out",
                                              Threshold = Level.All,
                                          };

            console.ActivateOptions();

            hierarchy.Root.AddAppender(console);

            RollingFileAppender rollingFile = new RollingFileAppender
                                                  {
                                                      Name = "file",
                                                      Layout = patternLayout,
                                                      AppendToFile = true,
                                                      RollingStyle = RollingFileAppender.RollingMode.Size,
                                                      MaxSizeRollBackups = 4,
                                                      MaximumFileSize = "100KB",
                                                      StaticLogFileName = true,
                                                      LockingModel = new FileAppender.MinimalLock(),
                                                      File = "logs\\logFile.txt",
                                                  };

            rollingFile.ActivateOptions();

            hierarchy.Root.AddAppender(rollingFile);

            RollbarAppender rollbar = new RollbarAppender
                                          {
                                              Name = "rollbar",
                                              Layout = patternLayout,
                                              AccessToken = "3203880e148b43b4b1a14430fb41957a",
                                              Threshold = Level.Notice,
                                          };

            rollbar.ActivateOptions();

            hierarchy.Root.AddAppender(rollbar);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;
        }
开发者ID:hallem,项目名称:log4net.RollbarSharp,代码行数:59,代码来源:RollbarAppenderTest.cs

示例10: DataTests

 static DataTests()
 {
     var layout = new PatternLayout("%-6timestamp %-5level - %message%newline");
     var appender = new ConsoleAppender { Layout = layout };
     layout.ActivateOptions();
     appender.ActivateOptions();
     BasicConfigurator.Configure(appender);
 }
开发者ID:TigerPapaDev,项目名称:named-pipe-wrapper,代码行数:8,代码来源:DataTests.cs

示例11: LogToConsoleAnd

 public static void LogToConsoleAnd(string logPath)
 {
     var layout = new PatternLayout("%-5level [%d{HH:mm:ss}] %-20.20logger{1}: %message%newline");
     var file = new RollingFileAppender {AppendToFile = false, File = logPath, Layout = layout, Encoding = Encoding.UTF8};
     file.ActivateOptions();
     var console = new ConsoleAppender {Layout = layout};
     console.ActivateOptions();
     BasicConfigurator.Configure(console, file);
 }
开发者ID:vorou,项目名称:overseer,代码行数:9,代码来源:LogConfigurator.cs

示例12: GetConsoleAppender

        private static ConsoleAppender GetConsoleAppender()
        {
            var consoleAppender = new ConsoleAppender()
            {
                Name = "ConsoleAppender",
                Layout = GetPatternLayout(),
                Threshold = Level.Info
            };

            consoleAppender.ActivateOptions();
            return consoleAppender;
        }
开发者ID:rahulrathore44,项目名称:ParkandCompanyCSharp,代码行数:12,代码来源:LoggerHelper.cs

示例13: SetUpConsole

		public static void SetUpConsole(string pattern = DefaultPattern)
		{
			var layout = new PatternLayout(pattern);
			var appender = new ConsoleAppender
			{
				Layout = layout,
				Threshold = Level.Debug
			};
			layout.ActivateOptions();
			appender.ActivateOptions();
			BasicConfigurator.Configure(appender);
		}
开发者ID:ntung,项目名称:ToolsPack.Net,代码行数:12,代码来源:Log4netQuickSetup.cs

示例14: GetConsoleAppender

        private static ConsoleAppender GetConsoleAppender()
        {
            var appender = new ConsoleAppender
            {
                Name = "Console",
                Layout = new SimpleLayout(),
                Threshold = Level.Debug
            };

            appender.ActivateOptions();
            return appender;
        }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:12,代码来源:Log4NetConfig.cs

示例15: Main

		public static void Main(string[] args)
		{
			var appender = new ConsoleAppender() {Layout = new PatternLayout("%-5p %x %m%n")};
			appender.ActivateOptions();

			BasicConfigurator.Configure(appender);

			var program = new Program(new DefaultConsole());
			ExitCode exitCode = program.Run(args);

			Environment.Exit((int) exitCode);
		}
开发者ID:emmekappa,项目名称:machine.migrations,代码行数:12,代码来源:Program.cs


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