Do not expose error.
Drop from cache after rotation.
package com.yahoo.container.logging;
import com.yahoo.container.core.AccessLogConfig;
+import com.yahoo.io.NativeIO;
import com.yahoo.log.LogFileDb;
import java.io.File;
@@ -263,15 +264,28 @@ public class LogFileHandler extends StreamHandler {
numberOfRecords = 0;
lastRotationTime = now;
nextRotationTime = 0; //figure it out later (lazy evaluation)
- if (compressOnRotation && (oldFileName != null)) {
+ if ((oldFileName != null)) {
+ if (compressOnRotation) {
triggerCompression(oldFileName);
+ } else {
+ NativeIO nativeIO = new NativeIO();
+ nativeIO.dropFileFromCache(new File(oldFileName));
+ }
}
}
private void triggerCompression(String oldFileName) {
try {
+ String zippedFileName = oldFileName + ".gz";
Runtime r = Runtime.getRuntime();
- Process p = r.exec(new String[] { "gzip", oldFileName });
+ StringBuilder cmd = new StringBuilder("gzip");
+ cmd.append(" < "). append(oldFileName).append(" > ").append(zippedFileName);
+ Process p = r.exec(cmd.toString());
+ NativeIO nativeIO = new NativeIO();
+ File oldFile = new File(oldFileName);
+ nativeIO.dropFileFromCache(oldFile);
+ oldFile.delete();
+ nativeIO.dropFileFromCache(new File(zippedFileName));
// Detonator pattern: Think of all the fun we can have if gzip isn't what we
// think it is, if it doesn't return, etc, etc
} catch (IOException e) {
