CollectorFormatter extends Formatter { @Override public String toString() { String result; try { result = formatRecord((Handler) null, false); } catch (final RuntimeException ignore) { result = super.toString(); } return result; } CollectorFormatter();  CollectorFormatter(String format);  CollectorFormatter(String format, Formatter f,
            Comparator<? super LogRecord> c); @Override String format(final LogRecord record); @Override String getTail(final Handler h); @Override String toString();  }
@Test public void testToString() { String msg = "message"; CollectorFormatter f = new CollectorFormatter("{3}", (Formatter) null, (Comparator<LogRecord>) null); f.format(new LogRecord(Level.SEVERE, msg)); f.format(new LogRecord(Level.SEVERE, msg)); f.format(new LogRecord(Level.SEVERE, msg)); f.format(new LogRecord(Level.SEVERE, msg)); String result = f.toString(); assertEquals(result, f.toString()); assertEquals(result, f.getTail((Handler) null)); assertFalse(result.equals(f.toString())); }