summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java209
1 files changed, 145 insertions, 64 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java b/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
index 4426a7aeec..54ca574871 100644
--- a/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
+++ b/qpid/java/broker/src/main/java/org/apache/log4j/QpidCompositeRollingAppender.java
@@ -20,6 +20,11 @@
*/
package org.apache.log4j;
+import org.apache.log4j.helpers.CountingQuietWriter;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.LoggingEvent;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -33,11 +38,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.GZIPOutputStream;
-import org.apache.log4j.helpers.CountingQuietWriter;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LoggingEvent;
-
/**
* <p>CompositeRollingAppender combines RollingFileAppender and DailyRollingFileAppender<br> It can function as either
* or do both at the same time (making size based rolling files like RollingFileAppender until a data/time boundary is
@@ -99,59 +99,38 @@ public class QpidCompositeRollingAppender extends FileAppender
private long nextCheck = System.currentTimeMillis() - 1;
/** Holds date of last roll over */
- Date now = new Date();
+ private Date now = new Date();
- SimpleDateFormat sdf;
+ private SimpleDateFormat sdf;
/** Helper class to determine next rollover time */
- RollingCalendar rc = new RollingCalendar();
+ private RollingCalendar rc = new RollingCalendar();
- /** The default maximum file size is 10MB. */
- protected long maxFileSize = 10 * 1024 * 1024;
+ private long maxFileSize = 10 * 1024 * 1024;
- /** There is zero backup files by default. */
- protected int maxSizeRollBackups = 0;
- /** How many sized based backups have been made so far */
- protected int curSizeRollBackups = 0;
+ private int maxSizeRollBackups = 0;
+ private int curSizeRollBackups = 0;
- /** not yet implemented */
- protected int maxTimeRollBackups = -1;
- protected int curTimeRollBackups = 0;
+ private int maxTimeRollBackups = -1;
+ private int curTimeRollBackups = 0;
- /**
- * By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th
- * backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup
- * made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs.
- */
- protected int countDirection = -1;
+ private int countDirection = -1;
- /** Style of rolling to Use. BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) */
- protected int rollingStyle = BY_COMPOSITE;
- protected boolean rollDate = true;
- protected boolean rollSize = true;
+ private int rollingStyle = BY_COMPOSITE;
+ private boolean rollDate = true;
+ private boolean rollSize = true;
- /**
- * By default file.log is always the current file. Optionally file.log.yyyy-mm-dd for current formated datePattern
- * can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup)
- * This will make time based roll overs with a large number of backups much faster -- it won't have to rename all
- * the backups!
- */
- protected boolean staticLogFileName = true;
+ private boolean staticLogFileName = true;
- /** FileName provided in configuration. Used for rolling properly */
- protected String baseFileName;
+ private String baseFileName;
- /** Do we want to .gz our backup files. */
- protected boolean compress = false;
+ private boolean compress = false;
- /** Do we want to use a second thread when compressing our backup files. */
- protected boolean compressAsync = false;
+ private boolean compressAsync = false;
- /** Do we want to start numbering files at zero. */
- protected boolean zeroBased = false;
+ private boolean zeroBased = false;
- /** Path provided in configuration. Used for moving backup files to */
- protected String backupFilesToPath = null;
+ private String backupFilesToPath = null;
private final ConcurrentLinkedQueue<CompressJob> _compress = new ConcurrentLinkedQueue<CompressJob>();
private AtomicBoolean _compressing = new AtomicBoolean(false);
private static final String COMPRESS_EXTENSION = ".gz";
@@ -219,7 +198,7 @@ public class QpidCompositeRollingAppender extends FileAppender
return datePattern;
}
- /** Returns the value of the <b>maxSizeRollBackups</b> option. */
+ /** There is zero backup files by default. */ /** Returns the value of the <b>maxSizeRollBackups</b> option. */
public int getMaxSizeRollBackups()
{
return maxSizeRollBackups;
@@ -311,7 +290,6 @@ public class QpidCompositeRollingAppender extends FileAppender
c.setType(i);
Date next = new Date(c.getNextCheckMillis(epoch));
String r1 = sdf.format(next);
- // LogLog.debug("Type = "+i+", r0 = "+r0+", r1 = "+r1);
if ((r0 != null) && (r1 != null) && !r0.equals(r1))
{
return i;
@@ -379,6 +357,11 @@ public class QpidCompositeRollingAppender extends FileAppender
}
}
+ /**
+ * By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th
+ * backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup
+ * made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs.
+ */
public int getCountDirection()
{
return countDirection;
@@ -389,6 +372,7 @@ public class QpidCompositeRollingAppender extends FileAppender
countDirection = direction;
}
+ /** Style of rolling to Use. BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) */
public int getRollingStyle()
{
return rollingStyle;
@@ -420,19 +404,6 @@ public class QpidCompositeRollingAppender extends FileAppender
}
}
- /*
- public void setRollingStyle(String style) {
- if (style == S_BY_SIZE) {
- rollingStyle = BY_SIZE;
- }
- else if (style == S_BY_DATE) {
- rollingStyle = BY_DATE;
- }
- else if (style == S_BY_COMPOSITE) {
- rollingStyle = BY_COMPOSITE;
- }
- }
- */
public boolean getStaticLogFileName()
{
return staticLogFileName;
@@ -484,6 +455,7 @@ public class QpidCompositeRollingAppender extends FileAppender
zeroBased = z;
}
+ /** Path provided in configuration. Used for moving backup files to */
public String getBackupFilesToPath()
{
return backupFilesToPath;
@@ -549,7 +521,6 @@ public class QpidCompositeRollingAppender extends FileAppender
now.setTime(System.currentTimeMillis());
sdf = new SimpleDateFormat(datePattern);
int type = computeCheckPeriod();
- // printPeriodicity(type);
rc.setType(type);
// next line added as this removes the name check in rollOver
nextCheck = rc.getNextCheckMillis(now);
@@ -797,7 +768,9 @@ public class QpidCompositeRollingAppender extends FileAppender
curSizeRollBackups--;
}
}
- // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
+ /*
+ map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}.
+ */
for (int i = curSizeRollBackups; i >= 1; i--)
{
String oldName = (fileName + "." + i);
@@ -1074,9 +1047,117 @@ public class QpidCompositeRollingAppender extends FileAppender
}
}
+ /** The default maximum file size is 10MB. */
+ protected long getMaxFileSize()
+ {
+ return maxFileSize;
+ }
+
+ /** How many sized based backups have been made so far */
+ protected int getCurSizeRollBackups()
+ {
+ return curSizeRollBackups;
+ }
+
+ protected void setCurSizeRollBackups(int curSizeRollBackups)
+ {
+ this.curSizeRollBackups = curSizeRollBackups;
+ }
+
+ /** not yet implemented */
+ protected int getMaxTimeRollBackups()
+ {
+ return maxTimeRollBackups;
+ }
+
+ protected void setMaxTimeRollBackups(int maxTimeRollBackups)
+ {
+ this.maxTimeRollBackups = maxTimeRollBackups;
+ }
+
+ protected int getCurTimeRollBackups()
+ {
+ return curTimeRollBackups;
+ }
+
+ protected void setCurTimeRollBackups(int curTimeRollBackups)
+ {
+ this.curTimeRollBackups = curTimeRollBackups;
+ }
+
+ protected boolean isRollDate()
+ {
+ return rollDate;
+ }
+
+ protected void setRollDate(boolean rollDate)
+ {
+ this.rollDate = rollDate;
+ }
+
+ protected boolean isRollSize()
+ {
+ return rollSize;
+ }
+
+ protected void setRollSize(boolean rollSize)
+ {
+ this.rollSize = rollSize;
+ }
+
+ /**
+ * By default file.log is always the current file. Optionally file.log.yyyy-mm-dd for current formated datePattern
+ * can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup)
+ * This will make time based roll overs with a large number of backups much faster -- it won't have to rename all
+ * the backups!
+ */
+ protected boolean isStaticLogFileName()
+ {
+ return staticLogFileName;
+ }
+
+ /** FileName provided in configuration. Used for rolling properly */
+ protected String getBaseFileName()
+ {
+ return baseFileName;
+ }
+
+ protected void setBaseFileName(String baseFileName)
+ {
+ this.baseFileName = baseFileName;
+ }
+
+ /** Do we want to .gz our backup files. */
+ protected boolean isCompress()
+ {
+ return compress;
+ }
+
+ protected void setCompress(boolean compress)
+ {
+ this.compress = compress;
+ }
+
+ /** Do we want to use a second thread when compressing our backup files. */
+ protected boolean isCompressAsync()
+ {
+ return compressAsync;
+ }
+
+ /** Do we want to start numbering files at zero. */
+ protected boolean isZeroBased()
+ {
+ return zeroBased;
+ }
+
+ protected void setBackupFilesToPath(String backupFilesToPath)
+ {
+ this.backupFilesToPath = backupFilesToPath;
+ }
+
private static class CompressJob
{
- File _from, _to;
+ private File _from, _to;
CompressJob(File from, File to)
{
@@ -1095,9 +1176,9 @@ public class QpidCompositeRollingAppender extends FileAppender
}
}
- Compressor compressor = null;
+ private Compressor compressor = null;
- Executor executor;
+ private Executor executor;
private class Compressor implements Runnable
{