@Override protected void before() throws Throwable { oldLevel = statusLogger.getLevel(); statusLogger.setLevel(level); }
protected static void checkStaticState(boolean afterClass) throws Exception { if (afterClass) { MockPageCacheRecycler.ensureAllPagesAreReleased(); } MockBigArrays.ensureAllArraysAreReleased(); // ensure no one changed the status logger level on us assertThat(StatusLogger.getLogger().getLevel(), equalTo(Level.WARN)); synchronized (statusData) { try { // ensure that there are no status logger messages which would indicate a problem with our Log4j usage; we map the // StatusData instances to Strings as otherwise their toString output is useless assertThat( statusData.stream().map(status -> status.getMessage().getFormattedMessage()).collect(Collectors.toList()), empty()); } finally { // we clear the list so that status data from other tests do not interfere with tests within the same JVM statusData.clear(); } } }
Level oldLevel = statusLogger.getLevel(); statusLogger.setLevel(Level.OFF);