Beispiel #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();
        }