QpidCompositeRollingAppender.java 文件源码

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

项目:andes 作者:
/**
 * Implements roll overs base on file size.
 *
 * <p>If the maximum number of size based backups is reached (<code>curSizeRollBackups == maxSizeRollBackups</code)
 * then the oldest file is deleted -- it's index determined by the sign of countDirection.<br> If
 * <code>countDirection</code> < 0, then files {<code>File.1</code>, ..., <code>File.curSizeRollBackups -1</code>}
 * are renamed to {<code>File.2</code>, ..., <code>File.curSizeRollBackups</code>}.  Moreover, <code>File</code> is
 * renamed <code>File.1</code> and closed.<br>
 *
 * A new file is created to receive further log output.
 *
 * <p>If <code>maxSizeRollBackups</code> is equal to zero, then the <code>File</code> is truncated with no backup
 * files created.
 *
 * <p>If <code>maxSizeRollBackups</code> < 0, then <code>File</code> is renamed if needed and no files are deleted.
 */

// synchronization not necessary since doAppend is alreasy synched
protected void rollOverSize()
{
    File file;

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

    LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
    LogLog.debug("maxSizeRollBackups = " + maxSizeRollBackups);
    LogLog.debug("curSizeRollBackups = " + curSizeRollBackups);
    LogLog.debug("countDirection = " + countDirection);

    // If maxBackups <= 0, then there is no file renaming to be done.
    if (maxSizeRollBackups != 0)
    {
        rollFile();
    }

    try
    {
        // This will also close the file. This is OK since multiple
        // close operations are safe.
        this.setFile(baseFileName, false);
    }
    catch (IOException e)
    {
        LogLog.error("setFile(" + fileName + ", false) call failed.", e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号