public static void apply(LoggingConfiguration conf) { apply(conf, "/org/sonar/batch/bootstrapper/logback.xml"); }
private void configureLogging() { if (loggingConfig != null) { loggingConfig.setProperties(globalProperties); LoggingConfigurator.apply(loggingConfig); } }
@Test public void testNoStdout() throws UnsupportedEncodingException { System.setOut(new PrintStream(out, false, StandardCharsets.UTF_8.name())); conf.setLogOutput(listener); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.error(TEST_STR); logger.info(TEST_STR); logger.debug(TEST_STR); assertThat(out.size()).isEqualTo(0); }
@Test public void testNoListener() throws UnsupportedEncodingException { System.setOut(new PrintStream(out, false, StandardCharsets.UTF_8.name())); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.info("info"); assertThat(new String(out.toByteArray(), StandardCharsets.UTF_8)).contains("info"); }
@Test public void testCustomAppender() throws UnsupportedEncodingException { conf.setLogOutput(listener); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.info(TEST_STR); assertThat(listener.msg).endsWith(TEST_STR); assertThat(listener.level).isEqualTo(LogOutput.Level.INFO); }
@Test public void testConfigureMultipleTimes() throws UnsupportedEncodingException { System.setOut(new PrintStream(out, false, StandardCharsets.UTF_8.name())); conf.setLogOutput(listener); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.debug("debug"); assertThat(listener.msg).isNull(); conf.setVerbose(true); LoggingConfigurator.apply(conf); logger.debug("debug"); assertThat(listener.msg).isEqualTo("debug"); }
@Test public void testFormatNoEffect() throws UnsupportedEncodingException { conf.setLogOutput(listener); conf.setFormat("%t"); LoggingConfigurator.apply(conf); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.info("info"); assertThat(listener.msg).isEqualTo("info"); }
@Test public void testWithFile() throws FileNotFoundException, IOException { InputStream is = this.getClass().getResourceAsStream(DEFAULT_CLASSPATH_CONF); File tmpFolder = folder.getRoot(); File testFile = new File(tmpFolder, "test"); OutputStream os = new FileOutputStream(testFile); IOUtils.copy(is, os); os.close(); conf.setLogOutput(listener); LoggingConfigurator.apply(conf, testFile); Logger logger = LoggerFactory.getLogger(this.getClass()); logger.info(TEST_STR); assertThat(listener.msg).endsWith(TEST_STR); assertThat(listener.level).isEqualTo(LogOutput.Level.INFO); }
public static void apply(LoggingConfiguration conf) { apply(conf, "/org/sonar/batch/bootstrapper/logback.xml"); }
public static void apply(LoggingConfiguration conf) { apply(conf, "/org/sonar/batch/bootstrapper/logback.xml"); }
private void configureLogging() { if (loggingConfig != null) { loggingConfig.setProperties(globalProperties); LoggingConfigurator.apply(loggingConfig); } }
private void configureTaskLogging(Map<String, String> taskProperties) { if (loggingConfig != null) { loggingConfig.setProperties(taskProperties, bootstrapProperties); LoggingConfigurator.apply(loggingConfig); } }
private void configureLogging() { if (loggingConfig != null) { loggingConfig.setProperties(bootstrapProperties); LoggingConfigurator.apply(loggingConfig); } }