private LoggingReader initLogging(Configuration configuration) throws IOException { Set<File> mainFiles = Sets.newHashSet(); Set<File> archiveDirectories = Sets.newHashSet(); LoggingFactory loggingFactory = configuration.getLoggingFactory(); if ( loggingFactory instanceof DefaultLoggingFactory ) { for ( AppenderFactory appenderFactory : ((DefaultLoggingFactory)loggingFactory).getAppenders() ) { if ( appenderFactory instanceof FileAppenderFactory ) { FileAppenderFactory fileAppenderFactory = (FileAppenderFactory)appenderFactory; if ( fileAppenderFactory.getCurrentLogFilename() != null ) { mainFiles.add(new File(fileAppenderFactory.getCurrentLogFilename()).getCanonicalFile()); } if ( fileAppenderFactory.getArchivedLogFilenamePattern() != null ) { File archive = new File(fileAppenderFactory.getArchivedLogFilenamePattern()).getParentFile().getCanonicalFile(); archiveDirectories.add(archive); } } } } if ( (mainFiles.size() == 0) && (archiveDirectories.size() == 0) ) { log.warn("No log files found in config"); } return new LoggingReader(mainFiles, archiveDirectories); }
/** * Creates the default appenders for a Heroku application. * * @return a single-element list containing a {@link #consoleAppender() console appender}. */ public static List<AppenderFactory> defaultAppenders() { return Lists.<AppenderFactory>newArrayList( consoleAppender() ); }
@Test public void defaultHerokuConsoleAppenders() { ImmutableList<AppenderFactory> appenders = factory.getAppenders(); assertThat(appenders.size(), is(1)); assertThat(appenders.get(0), is(instanceOf(HerokuConsoleAppenderFactory.class))); }