question: private File acquireUniqueFile ( final String originalFilename ) throws IOException { String filename = originalFilename ; int unique = 0 ; for ( ; ; ) { File f = new File ( filename ) ; createParentDirectories ( f ) ; boolean created = f . createNewFile ( ) ; if ( created ) { return f ; } else if ( append && ! sizeRollingPolicy . hasReachedLimit ( f ) ) { return f ; } else { ++ unique ; if ( originalFilename . endsWith ( ".log" ) ) { filename = originalFilename . replace ( ".log" , "__" + unique + ".log" ) ; } else { filename = originalFilename + "__" + unique ; } } } }
target:  Acquire a unique filename - use the original file name if possible, but if the file already exists, try and assign a unique incrementing index. If the 'append' property is enabled, then the existing file will be used.