Example #1
0
        public static void Configurar(LogConfiguration configuracao = null)
        {
            if (configuracao == null)
            {
                configuracao = new LogConfiguration();
            }

            AssistirArquivoDeConfiguracao();
            Root.Repository.ResetConfiguration();
            configuracao = configuracao.MergeWithSettingsConfig();

            var appenders = GetAppenders(configuracao);
            var loggers   = GetLoggers(configuracao);

            foreach (var appender in appenders)
            {
                if (appender.ShouldBeEnable)
                {
                    foreach (var logger in loggers)
                    {
                        if (logger.ShouldBeEnable)
                        {
                            logger.Logger.AddAppender(appender.Get());
                        }
                    }
                }
            }

            Configuracao = configuracao;
            Root.Repository.Configured = true;
        }
Example #2
0
        private static IEnumerable <FrameworkAppender> GetAppenders(LogConfiguration configuracao)
        {
            yield return(new FileAppenderLog(configuracao));

            yield return(new DebugAppenderLog(configuracao));

            yield return(new ConsoleAppenderLog(configuracao));
        }
Example #3
0
        public ConsoleAppenderLog(LogConfiguration configuration) : base(configuration)
        {
            var consoleAppender = new ConsoleAppender
            {
                Name      = "ConsoleAppender",
                Layout    = new PatternLayout(this.configuration.ConsolePattern),
                Threshold = this.configuration.Level,
            };

            consoleAppender.ActivateOptions();

            this.appender = new SqlAppender();
            this.appender.AddAppender(consoleAppender);
        }
        public DebugAppenderLog(LogConfiguration configuration) : base(configuration)
        {
            var debugAppender = new DebugAppender
            {
                Name      = "TraceAppender",
                Layout    = new PatternLayout(this.configuration.ConsolePattern),
                Threshold = this.configuration.Level
            };

            debugAppender.ActivateOptions();

            this.appender = new SqlAppender();
            this.appender.AddAppender(debugAppender);
        }
        public FileAppenderLog(LogConfiguration configuration)
            : base(configuration)
        {
            var fileAppender = new RollingFileAppender
            {
                Name               = "FileAppender",
                AppendToFile       = true,
                File               = Path.Combine("Logs", this.configuration.NomeDoArquivo + ".log"),
                Layout             = new PatternLayout("%date [%5.5thread] [%-5.5level] > %message %newline"),
                Threshold          = this.configuration.Level,
                RollingStyle       = RollingFileAppender.RollingMode.Size,
                StaticLogFileName  = true,
                MaxSizeRollBackups = 10,
                MaximumFileSize    = "30MB"
            };

            fileAppender.ActivateOptions();

            this.appender = new SqlAppender();
            this.appender.AddAppender(fileAppender);
        }
Example #6
0
 protected FrameworkAppender(LogConfiguration configuration)
 {
     this.configuration = configuration;
 }
Example #7
0
        private static IEnumerable <BaseLogger> GetLoggers(LogConfiguration configuracao)
        {
            yield return(new ApplicationLogger(configuracao, Root.Repository));

            yield return(new FrameworkLogger(configuracao, Root.Repository));
        }
 public FrameworkLogger(LogConfiguration configuration, ILoggerRepository loggerRepository)
     : base(configuration, loggerRepository)
 {
     this.Logger = (Logger)loggerRepository.GetLogger("Framework");
 }
Example #9
0
 protected BaseLogger(LogConfiguration configuration, ILoggerRepository loggerRepository)
 {
     this.configuration    = configuration;
     this.loggerRepository = loggerRepository;
 }
Example #10
0
 public ApplicationLogger(LogConfiguration configuration, ILoggerRepository loggerRepository)
     : base(configuration, loggerRepository)
 {
     this.Logger = (Logger)loggerRepository.GetLogger("Application");
 }