RollingFileWithoutDeleteAppender extends FileAppender { public void rollOver() { if (qw != null) { long size = ((CountingQuietWriter) qw).getCount(); LogLog.debug("rolling over count=" + size); nextRollover = size + maxFileSize; } this.closeFile(); String newFileName = getLogFileName(fileName); try { this.setFile(newFileName, false, bufferedIO, bufferSize); nextRollover = 0; } catch (IOException e) { if (e instanceof InterruptedIOException) { Thread.currentThread().interrupt(); } LogLog.error("setFile(" + newFileName + ", false) call failed.", e); } } RollingFileWithoutDeleteAppender();  RollingFileWithoutDeleteAppender(Layout layout, String filename,
      boolean append);  RollingFileWithoutDeleteAppender(Layout layout, String filename); long getMaximumFileSize(); void rollOver(); synchronized void setFile(String fileName, boolean append,
      boolean bufferedIO, int bufferSize); void setMaximumFileSize(long maxFileSize); void setMaxFileSize(String value);  }
@Test public void testRollOver() throws Throwable { if (dataDir == null) { fail("Excepted temp folder for audit log is created."); } RollingFileWithoutDeleteAppender appender = new RollingFileWithoutDeleteAppender( new PatternLayout("%m%n"), dataDir.getPath() + "/auditLog.log"); appender.setMaximumFileSize(100); sentryLogger.addAppender(appender); for (int i = 0; i < 99; i++) { if (i < 10) { sentryLogger.debug("Hello---" + i); } else if (i < 100) { sentryLogger.debug("Hello--" + i); } } if (dataDir != null) { File[] files = dataDir.listFiles(); if (files != null) { assertEquals(files.length, 10); } else { fail("Excepted 10 log files."); } } else { fail("Excepted 10 log files."); } }