Java Utililty Methods Log Rotate

List of utility methods to do Log Rotate

Description

The list of methods to do Log Rotate are organized into topic(s).

Method

voidrotateLog()
rotate Log
int maxLogs = 2;
File last = new File("client-" + maxLogs + ".log");
if (last.exists()) {
    if (!last.delete()) {
        System.err.println("Error removing old log file:" + last);
for (int i = maxLogs - 1; i > 0; i--) {
...
voidrotateLogs(File where, String basename, int max)
rotate Logs
File logfile = new File(where, String.format("%s-%02d.log", basename, max));
if (logfile.exists()) {
    logfile.delete();
if (max > 0) {
    File previous = new File(where, String.format("%s-%02d.log", basename, max - 1));
    if (previous.exists()) {
        previous.renameTo(logfile);
...