示例#1
0
        protected override void configureLogging(String level)
        {
            base.configureLogging(level);
            var fileName = Path.Combine(LogDirectoryFinderFactory.get().find().getAbsolute(),
                                        getProperty("application.name").ToLower().Replace(" ", "") + ".log");
            LoggerContext ctx      = (LoggerContext)LogManager.getContext(false);
            Configuration config   = ctx.getConfiguration();
            Appender      appender =
                ((RollingFileAppender.Builder)((RollingFileAppender.Builder)RollingFileAppender.newBuilder()
                                               .setName(typeof(RollingFileAppender).Name))
                 .withFileName(fileName)
                 .withFilePattern(fileName)
                 .withPolicy(Level.DEBUG.toString().Equals(level)
                        ? SizeBasedTriggeringPolicy.createPolicy("250MB")
                        : SizeBasedTriggeringPolicy.createPolicy("10MB"))
                 .withStrategy(DefaultRolloverStrategy.newBuilder().withMin("1").withMax("1").build())
                 .setLayout(PatternLayout.newBuilder().withConfiguration(config)
                            .withPattern("%d [%t] %-5p %c - %m%n").withCharset(StandardCharsets.UTF_8).build()))
                .build();

            appender.start();
            config.addAppender(appender);
            config.getRootLogger().addAppender(appender, null, null);
            if (Debugger.IsAttached)
            {
                Configurator.setRootLevel(Level.DEBUG);
            }

            ctx.updateLoggers();
        }
示例#2
0
        protected override void configureLogging(String level)
        {
            base.configureLogging(level);

            Logger root     = Logger.getRootLogger();
            var    fileName = Path.Combine(LogDirectoryFinderFactory.get().find().getAbsolute(),
                                           getProperty("application.name").ToLower().Replace(" ", "") + ".log");
            RollingFileAppender appender = new RollingFileAppender(new PatternLayout(@"%d [%t] %-5p %c - %m%n"),
                                                                   fileName, true);

            appender.setEncoding("UTF-8");
            appender.setMaxFileSize(Level.DEBUG.ToString().Equals(level) ? "250MB" : "10MB");
            appender.setMaxBackupIndex(0);
            root.addAppender(appender);
            if (Debugger.IsAttached)
            {
                root.setLevel(Level.DEBUG);
            }
        }