Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.yammer.dropwizard.logging;
  
 
 import static com.yammer.dropwizard.config.LoggingConfiguration.*;
 
 public class LogbackFactory {
     private LogbackFactory() { /* singleton */ }
 
     public static SyslogAppender buildSyslogAppender(SyslogConfiguration syslog,
                                                      LoggerContext context,
                                                      String name,
                                                      Optional<StringlogFormat) {
         final SyslogAppender appender = new SyslogAppender();
         appender.setName(name);
         appender.setContext(context);
         appender.setSyslogHost(syslog.getHost());
         appender.setFacility(syslog.getFacility().toString());
         addThresholdFilter(appendersyslog.getThreshold());
 
         for (String format : logFormat.asSet()) {
             appender.setSuffixPattern(format);
         }
 
         appender.start();
 
         return appender;
     }
 
                                                                        LoggerContext context,
                                                                        Optional<StringlogFormat) {
         final LogFormatter formatter = new LogFormatter(contextfile.getTimeZone());
         for (String format : logFormat.asSet()) {
             formatter.setPattern(format);
         }
         formatter.start();
 
         final FileAppender<ILoggingEventappender = 
             file.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
                                new FileAppender<ILoggingEvent>();
 
         appender.setAppend(true);
         appender.setContext(context);
         appender.setLayout(formatter);
         appender.setFile(file.getCurrentLogFilename());
         appender.setPrudent(false);
 
         addThresholdFilter(appenderfile.getThreshold());
 
         if (file.isArchive()) {
 
             final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEventtriggeringPolicy =
                     new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
             triggeringPolicy.setContext(context);
 
             final TimeBasedRollingPolicy<ILoggingEventrollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
             rollingPolicy.setContext(context);
             rollingPolicy.setFileNamePattern(file.getArchivedLogFilenamePattern());
             rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(
                     triggeringPolicy);
             triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
             rollingPolicy.setMaxHistory(file.getArchivedFileCount());
 
             ((RollingFileAppender<ILoggingEvent>) appender).setRollingPolicy(rollingPolicy);
             ((RollingFileAppender<ILoggingEvent>) appender).setTriggeringPolicy(triggeringPolicy);
 
             rollingPolicy.setParent(appender);
             rollingPolicy.start();
         }
 
         appender.stop();
         appender.start();
 
         return appender;
     }
 
                                                                       LoggerContext context,
                                                                       Optional<StringlogFormat) {
         final LogFormatter formatter = new LogFormatter(contextconsole.getTimeZone());
         for (String format : logFormat.asSet()) {
             formatter.setPattern(format);
         }
         formatter.start();
 
         final ConsoleAppender<ILoggingEventappender = new ConsoleAppender<ILoggingEvent>();
         appender.setContext(context);
        appender.setLayout(formatter);
        addThresholdFilter(appenderconsole.getThreshold());
        appender.start();
        return appender;
    }
    private static void addThresholdFilter(FilterAttachable<ILoggingEventappenderLevel threshold) {
        final ThresholdFilter filter = new ThresholdFilter();
        filter.setLevel(threshold.toString());
        filter.start();
        appender.addFilter(filter);
    }
New to GrepCode? Check out our FAQ X