private void addBackup ( ) { // move the current log file to the newly formatted backup name String newname = this . fileinfo + this . myFormat . format ( new Date ( HttpDispatcher . getApproxTime ( ) ) ) + this . extensioninfo ; File newFile = new File ( newname ) ; renameFile ( this . myFile , newFile ) ; // now see if we need to delete an existing backup to make room if ( this . backups . size ( ) == getMaximumBackupFiles ( ) ) { File oldest = this . backups . removeLast ( ) ; if ( null != oldest && oldest . exists ( ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , getFileName ( ) + ": Purging oldest backup-> " + oldest . getName ( ) ) ; } oldest . delete ( ) ; } } this . backups . addFirst ( newFile ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , getFileName ( ) + ": number of backup files-> " + this . backups . size ( ) ) ; } }
Move the current logfile to a backup name taking care of any existing backup files according to the configured limit .