Beispiel #1
0
        private static LevelRangeFilter GetLevelRange(Log4NetAppenderConfig appenderConfig)
        {
            var rangeFilter = new LevelRangeFilter
            {
                LevelMin = GetLevel(appenderConfig.LevelMin),
                LevelMax = GetLevel(appenderConfig.LevelMax)
            };

            return(rangeFilter);
        }
Beispiel #2
0
        private static IAppender LoadRollingFileAppender(Log4NetAppenderConfig appenderConfig)
        {
            var roller = new RollingFileAppender();

            if (!string.IsNullOrWhiteSpace(appenderConfig.ConversionPattern))
            {
                var patternLayout = new PatternLayout {
                    ConversionPattern = appenderConfig.ConversionPattern
                };
                patternLayout.ActivateOptions();
                roller.Layout = patternLayout;
            }

            roller.File = appenderConfig.File;

            if (appenderConfig.AppendToFile != null)
            {
                roller.AppendToFile = appenderConfig.AppendToFile.Value;
            }

            if (appenderConfig.MaxSizeRollBackups != null)
            {
                roller.MaxSizeRollBackups = (int)appenderConfig.MaxSizeRollBackups;
            }

            if (appenderConfig.StaticLogFileName != null)
            {
                roller.StaticLogFileName = (bool)appenderConfig.StaticLogFileName;
            }

            if (appenderConfig.RollingStyle != RollingStyles.NotSet)
            {
                roller.RollingStyle = GetRollingMode(appenderConfig.RollingStyle);
            }

            if (!string.IsNullOrWhiteSpace(appenderConfig.DatePattern))
            {
                roller.DatePattern = appenderConfig.DatePattern;
            }

            var rangeFilter = GetLevelRange(appenderConfig);

            if (rangeFilter != null)
            {
                roller.AddFilter(rangeFilter);
            }

            roller.ActivateOptions();
            return(roller);
        }
Beispiel #3
0
        private static IAppender LoadConsoleAppender(Log4NetAppenderConfig appenderConfig)
        {
            var appender = new ConsoleAppender();

            if (!string.IsNullOrWhiteSpace(appenderConfig.ConversionPattern))
            {
                var patternLayout = new PatternLayout {
                    ConversionPattern = appenderConfig.ConversionPattern
                };
                patternLayout.ActivateOptions();
                appender.Layout = patternLayout;
            }

            appender.ActivateOptions();
            return(appender);
        }