RollingFileWithoutDeleteAppender.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:incubator-sentry 作者:
/**
 * Implements the usual roll over behaviour.
 * <p>
 * <code>File</code> is renamed <code>File.yyyyMMddHHmmss</code> and closed. A
 * new <code>File</code> is created to receive further log output.
 */
// synchronization not necessary since doAppend is alreasy synched
public void rollOver() {
  if (qw != null) {
    long size = ((CountingQuietWriter) qw).getCount();
    LogLog.debug("rolling over count=" + size);
    // if operation fails, do not roll again until
    // maxFileSize more bytes are written
    nextRollover = size + maxFileSize;
  }

  this.closeFile(); // keep windows happy.

  String newFileName = getLogFileName(fileName);
  try {
    // This will also close the file. This is OK since multiple
    // close operations are safe.
    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);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号