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


C# RollingFileAppender.ActivateOptions方法代码示例

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


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

示例1: Log4NetAdapter

        /// <summary>
        /// 初始化一个<see cref="Log4NetAdapter"/>类型的新实例
        /// </summary>k
        public Log4NetAdapter()
        {
//            var configFile = Path.Combine(ConfigPath, FileName);
//            if (File.Exists(configFile))
//            {
//                XmlConfigurator.ConfigureAndWatch(new FileInfo(configFile));
//                return;
//            }
            var appender = new RollingFileAppender
            {
                Name = "root",
                File = "logs\\log_",
                AppendToFile = true,
                LockingModel = new FileAppender.MinimalLock(),
                RollingStyle = RollingFileAppender.RollingMode.Date,
                DatePattern = "yyyyMMdd-HH\".log\"",
                StaticLogFileName = false,
                MaxSizeRollBackups = 10,
                Layout = new PatternLayout("[%d{yyyy-MM-dd HH:mm:ss.fff}] %-5p %c %t %w %n%m%n")
                //Layout = new PatternLayout("[%d [%t] %-5p %c [%x] - %m%n]")
            };
            appender.ClearFilters();
            appender.AddFilter(new LevelRangeFilter
            {
                LevelMin = Level.Debug,
                LevelMax = Level.Fatal
            });
            BasicConfigurator.Configure(appender);
            appender.ActivateOptions();
        }
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:33,代码来源:Log4NetAdapter.cs

示例2: Setup

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

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

            var roller = new RollingFileAppender();
            roller.AppendToFile = true;
            roller.File = path;
            roller.Layout = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize = "2MB";
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

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

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
开发者ID:StefanMihaylov,项目名称:PerforceBackup,代码行数:27,代码来源:Log4netSettings.cs

示例3: SetupLoggers

        private static void SetupLoggers()
        {
            var hierarchy = (Hierarchy)LogManager.GetRepository();

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

            var fileAppender = new RollingFileAppender
            {
                AppendToFile = false,
                File = Constants.InstallationLog,
                Layout = patternLayout,
                MaxSizeRollBackups = 3,
                MaximumFileSize = "1GB",
                RollingStyle = RollingFileAppender.RollingMode.Size,
                StaticLogFileName = false
            };
            fileAppender.ActivateOptions();
            hierarchy.Root.AddAppender(fileAppender);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
开发者ID:Kittyfisto,项目名称:Tailviewer,代码行数:26,代码来源:App.cs

示例4: Setup

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

			var patternLayout = new PatternLayout();
			patternLayout.ConversionPattern = "%date{yyyy-MM-dd HH:mm:ss.fff} %-6level  %message%newline";
			patternLayout.ActivateOptions();

			var roller = new RollingFileAppender();
			roller.AppendToFile = true;
			roller.File = LostKeysUnited.Location.FullName + ".log";
			roller.Layout = patternLayout;
			roller.MaxSizeRollBackups = 5;
			roller.MaximumFileSize = "1GB";
			roller.RollingStyle = RollingFileAppender.RollingMode.Size;
			roller.StaticLogFileName = true;
			roller.ActivateOptions();
			hierarchy.Root.AddAppender(roller);
#if DEBUG
			hierarchy.Root.Level = Level.Debug;
#else
			hierarchy.Root.Level = Level.Error;
#endif
			hierarchy.Configured = true;
		}
开发者ID:Corniel,项目名称:CloudBall.LostKeysUnited,代码行数:25,代码来源:Logging.cs

示例5: Log4NetLogFactory

        public Log4NetLogFactory(LogFileSettings settings)
        {
            var patternLayout = new log4net.Layout.PatternLayout(
                "%date [%thread] %level %logger - %message%newline");
            patternLayout.ActivateOptions();

            RollingFileAppender appender
                = new RollingFileAppender
                      {
                          Name = "rolling-appender",
                          File = Path.Combine(settings.DirectoryPath, settings.NamePrefix + ".log"),
                          AppendToFile = true,
                          MaxSizeRollBackups = 10,
                          RollingStyle = RollingFileAppender.RollingMode.Date,
                          Layout = patternLayout,
                          LockingModel = new FileAppender.MinimalLock()
                      };
            appender.ActivateOptions();


            log4net.Config.BasicConfigurator.Configure(appender);

            Hierarchy h = (Hierarchy)LogManager.GetRepository();
            Logger rootLogger = h.Root;
            rootLogger.Level = h.LevelMap[ConvertLogLevel(settings.Level).ToString().ToUpper()];
        }
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:26,代码来源:Log4NetLogFactory.cs

示例6: Logger

        static Logger()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
            TraceAppender tracer = new TraceAppender();
            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = LOG_PATTERN;
            patternLayout.ActivateOptions();

            tracer.Layout = patternLayout;
            tracer.ActivateOptions();
            hierarchy.Root.AddAppender(tracer);

            RollingFileAppender roller = new RollingFileAppender();
            roller.Layout = patternLayout;
            roller.AppendToFile = true;
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.MaxSizeRollBackups = 4;
            roller.MaximumFileSize = "32768KB";
            roller.StaticLogFileName = true;
            roller.File = "log\\Log.log";
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;
        }
开发者ID:dionata,项目名称:wfmvc,代码行数:27,代码来源:Logger.cs

示例7: Configure

        public static void Configure(string appfolder, string logFile)
        {
            bool isConfigured = _log.Logger.Repository.Configured;

            if (!isConfigured)
            {
                // Setup RollingFileAppender
                var fileAppender = new RollingFileAppender
                {
                    Layout =
                        new PatternLayout(
                        "%d %level [%type{1}] - %m%n"),
                    MaximumFileSize = "1000KB",
                    MaxSizeRollBackups = 10,
                    RollingStyle = RollingFileAppender.RollingMode.Composite,
                    AppendToFile = true,
                    File = logFile,
                    ImmediateFlush = true,
                    LockingModel = new FileAppender.MinimalLock(),
                    Name = "XXXRollingFileAppender",
                    Threshold = log4net.Core.Level.All
                };
                fileAppender.ActivateOptions(); // IMPORTANT, creates the file
                BasicConfigurator.Configure(fileAppender);
            #if DEBUG
                // Setup TraceAppender
                TraceAppender ta = new TraceAppender();
                ta.Layout = new PatternLayout("%d [%t]%-5p %c [%x] - %m%n");
                BasicConfigurator.Configure(ta);
            #endif
            }
        }
开发者ID:StephOfPixVert,项目名称:ShootingLab,代码行数:32,代码来源:LabCommonLog.cs

示例8: Logger

        static Logger()
        {
            var hierarchy = (Hierarchy)LogManager.GetRepository();
            var tracer = new TraceAppender();
            var patternLayout = new PatternLayout {ConversionPattern = LOG_PATTERN};

            patternLayout.ActivateOptions();

            tracer.Layout = patternLayout;
            tracer.ActivateOptions();
            hierarchy.Root.AddAppender(tracer);

            var roller = new RollingFileAppender
                             {
                                 Layout = patternLayout,
                                 AppendToFile = true,
                                 RollingStyle = RollingFileAppender.RollingMode.Size,
                                 MaxSizeRollBackups = 4,
                                 MaximumFileSize = "10240KB",
                                 StaticLogFileName = true,
                                 File = FilePath + @"\f1speed-log.txt"
                             };
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            hierarchy.Root.Level = Level.Debug;
            hierarchy.Configured = true;
        }
开发者ID:Malyngo,项目名称:DirtRallyWebTelemetry,代码行数:28,代码来源:Logging.cs

示例9: InitLog4net

        private static void InitLog4net()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();
            patternLayout.ConversionPattern = "[%date] %-5level [%thread] %property{user} - %message%exception%n";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();
            roller.AppendToFile = true;
            roller.File = @"logs\";
            roller.Layout = patternLayout;
            roller.MaxSizeRollBackups = 100;
            roller.MaximumFileSize = "10MB";
            roller.RollingStyle = RollingFileAppender.RollingMode.Date;
            roller.DatePattern = "yyyyMMdd'.log'";
            roller.StaticLogFileName = false;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;

            log4net.GlobalContext.Properties["user"] = new Log4NetUserNameProvider();
        }
开发者ID:zhh007,项目名称:CKGen,代码行数:25,代码来源:Bootstrap.cs

示例10: CLogger

        /// <summary>
        /// constructor that initialize logger name, file name and log level
        /// </summary>
        public CLogger(string sLoggerName, string sFilename, int iLogLevel)
        {
            ILog oLogger = LogManager.GetLogger(sLoggerName);
            string sLogFileName = string.Empty;
            sLogFileName = GetLogFileName(sFilename);

            m_oFPLogger = (log4net.Repository.Hierarchy.Logger)oLogger.Logger;
            log4net.Appender.RollingFileAppender oFPAppender = new RollingFileAppender();
            oFPAppender.File = sLogFileName;
            oFPAppender.MaxSizeRollBackups = 100;
            oFPAppender.MaximumFileSize = "1MB";
            oFPAppender.RollingStyle = RollingFileAppender.RollingMode.Size;
            oFPAppender.StaticLogFileName = true;
            oFPAppender.AppendToFile = true;
            log4net.Layout.PatternLayout layout = new log4net.Layout.PatternLayout();
            layout.ConversionPattern = "%d %-5p - %m%n%exception";
            layout.ActivateOptions();
            oFPAppender.Layout = layout;
            oFPAppender.ActivateOptions();
            /** Programmatically configuration will not work it it is not set true**/
            m_oFPLogger.Hierarchy.Configured = true;

            try
            {
                m_oFPLogger.AddAppender(oFPAppender);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to Add Appender", ex);
            }
            m_oFPLogger.Hierarchy.Root.Level = m_oFPLogger.Hierarchy.LevelMap[GetLogLevel(iLogLevel)];

            oLogger = null;
        }
开发者ID:krishnakanthms,项目名称:Online-Exam-tool,代码行数:37,代码来源:CLogger.cs

示例11: DefaultLogWrapper

        public DefaultLogWrapper(string logname, IConfig config)
        {
            this.logname = logname;

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

            TraceAppender tracer = new TraceAppender();
            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%t (%-5level) - %m%n";
            patternLayout.ActivateOptions();

            tracer.Layout = patternLayout;
            tracer.ActivateOptions();
            hierarchy.Root.AddAppender(tracer);

            RollingFileAppender roller = new RollingFileAppender();
            roller.Layout = patternLayout;
            roller.AppendToFile = true;
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.MaxSizeRollBackups = 4;
            roller.MaximumFileSize = "100KB";
            roller.StaticLogFileName = true;
            roller.File = Path.Combine(config.IndexFolder, "totalrecall-" + this.logname + ".log");
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;
        }
开发者ID:riadyb,项目名称:totalrecall,代码行数:31,代码来源:DefaultLogWrapper.cs

示例12: 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

示例13: Logging

    public Logging(string sFileName, string sLocation, bool bUseLogging)
    {
        m_sFileName = sFileName;
        if (!bUseLogging) return;

        if (sLocation.Length > 0)
            if (sLocation[sLocation.Length - 1] != '\\')
                sLocation += "\\";

        m_RFL = new log4net.Appender.RollingFileAppender();
        m_RFL.File = sLocation + m_sFileName + m_sFileExt;
        m_RFL.StaticLogFileName = true;
        m_RFL.AppendToFile = true;
        m_RFL.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Size;
        m_RFL.MaximumFileSize = "10mb";
        m_RFL.MaxSizeRollBackups = 2;
        m_RFL.Threshold = log4net.Core.Level.All;

        //m_RFL.CountDirection = 1;
        //m_RFL.DatePattern = "HH:MM::SS"; 
        log4net.Layout.PatternLayout layout = new log4net.Layout.PatternLayout("%message%newline");
        layout.ActivateOptions();
        log4net.Filter.LevelRangeFilter filter = new log4net.Filter.LevelRangeFilter();
        filter.LevelMax = log4net.Core.Level.Emergency;
        filter.LevelMin = log4net.Core.Level.All;
        m_RFL.AddFilter(filter);
        m_RFL.Layout = layout;
        m_RFL.ActivateOptions();

        log4net.Config.BasicConfigurator.Configure(m_RFL);

        // Set up
        Log(Logging.LOGTYPE.ERROR, "Start logging...");

    }
开发者ID:JmmBite-GFW,项目名称:dnscrypt-win-client,代码行数:35,代码来源:Logging.cs

示例14: Setup

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

            PatternLayout patternLayout = new PatternLayout();
            patternLayout.ConversionPattern = "%date{dd/MM/yyyy hh:mm:ss.fff tt} | %logger[%method:%line] %level - %message%newline%exception";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();
            roller.AppendToFile = false;
            roller.Encoding = Encoding.UTF8;
            roller.File = DataEx.log_Events;
            roller.Layout = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize = "5MB";
            roller.RollingStyle = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

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

            hierarchy.Root.Level = (bool)App.Current.Properties["Troubleshooting"] ? Level.Debug : Level.Info;
            hierarchy.Configured = true;

            doFirstEntry();
        }
开发者ID:berkay2578,项目名称:nfsw-server,代码行数:29,代码来源:Logger.cs

示例15: ConfigurePlugin

        protected override void ConfigurePlugin(PluginConfiguration pluginConfiguration, PluginInspector pluginInspector)
        {
            _moduleName = pluginConfiguration.ModuleName;
            BasicConfigurator.Configure();

            var defaultPattern = new PatternLayout { ConversionPattern = LogPattern };
            defaultPattern.ActivateOptions();

            var rollingFileAppender = new RollingFileAppender
            {
                Name = "RollingFileAppender",
                File = "Log/" + _moduleName + ".log",
                AppendToFile = true,
                RollingStyle = RollingFileAppender.RollingMode.Size,
                MaxSizeRollBackups = 15,
                MaximumFileSize = "100MB",
                StaticLogFileName = true,
                Layout = defaultPattern
            };
            rollingFileAppender.ActivateOptions();
            rollingFileAppender.ImmediateFlush = true;
            rollingFileAppender.LockingModel= new FileAppender.InterProcessLock();

            var root = ((Hierarchy)global::log4net.LogManager.GetRepository()).Root;
            root.AddAppender(rollingFileAppender);
            root.Level = Level.Debug;
            root.Repository.Configured = true;
        }
开发者ID:TicketArchitecture,项目名称:EasyArchitecture,代码行数:28,代码来源:Log4NetPlugin.cs


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