KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log4j > CompositeRollingAppender


1 package org.apache.log4j;
2
3 /*
4  * Copyright 1999-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import org.apache.log4j.RollingCalendar;
20 import org.apache.log4j.helpers.OptionConverter;
21 import org.apache.log4j.helpers.QuietWriter;
22 import org.apache.log4j.helpers.CountingQuietWriter;
23 import org.apache.log4j.helpers.LogLog;
24 import org.apache.log4j.spi.LoggingEvent;
25
26 import java.util.Date JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.io.Writer JavaDoc;
29 import java.text.SimpleDateFormat JavaDoc;
30 import java.io.File JavaDoc;
31 import java.io.FilenameFilter JavaDoc;
32
33 /**
34  * <p>CompositeRollingAppender combines RollingFileAppender and DailyRollingFileAppender<br>
35  * It can function as either or do both at the same time (making size
36  * based rolling files like RollingFileAppender until a data/time boundary
37  * is crossed at which time it rolls all of those files as per the DailyRollingFileAppender)
38  * based on the setting for <code>rollingStyle</code>.<br>
39  * <br>
40  * To use CompositeRollingAppender to roll log files as they reach a certain
41  * size (like RollingFileAppender), set rollingStyle=1 (@see config.size)<br>
42  * To use CompositeRollingAppender to roll log files at certain time intervals
43  * (daily for example), set rollingStyle=2 and a datePattern (@see config.time)<br>
44  * To have CompositeRollingAppender roll log files at a certain size AND rename those
45  * according to time intervals, set rollingStyle=3 (@see config.composite)<br>
46  *
47  * <p>A of few additional optional features have been added:<br>
48  * -- Attach date pattern for current log file (@see staticLogFileName)<br>
49  * -- Backup number increments for newer files (@see countDirection)<br>
50  * -- Infinite number of backups by file size (@see maxSizeRollBackups)<br>
51  * <br>
52  * <p>A few notes and warnings: For large or infinite number of backups
53  * countDirection > 0 is highly recommended, with staticLogFileName = false if
54  * time based rolling is also used -- this will reduce the number of file renamings
55  * to few or none. Changing staticLogFileName or countDirection without clearing
56  * the directory could have nasty side effects. If Date/Time based rolling
57  * is enabled, CompositeRollingAppender will attempt to roll existing files
58  * in the directory without a date/time tag based on the last modified date
59  * of the base log files last modification.<br>
60  * <br>
61  * <p>A maximum number of backups based on date/time boundries would be nice
62  * but is not yet implemented.<br>
63  *
64  * @author Kevin Steppe
65  * @author Heinz Richter
66  * @author Eirik Lygre
67  * @author Ceki G&uuml;lc&uuml;
68  */

69 public class CompositeRollingAppender extends org.apache.log4j.FileAppender
70 {
71     // The code assumes that the following 'time' constants are in a increasing
72
// sequence.
73
static final int TOP_OF_TROUBLE=-1;
74     static final int TOP_OF_MINUTE = 0;
75     static final int TOP_OF_HOUR = 1;
76     static final int HALF_DAY = 2;
77     static final int TOP_OF_DAY = 3;
78     static final int TOP_OF_WEEK = 4;
79     static final int TOP_OF_MONTH = 5;
80
81     /** Style of rolling to use */
82     static final int BY_SIZE = 1;
83     static final int BY_DATE = 2;
84     static final int BY_COMPOSITE = 3;
85
86     //Not currently used
87
static final String JavaDoc S_BY_SIZE = "Size";
88     static final String JavaDoc S_BY_DATE = "Date";
89     static final String JavaDoc S_BY_COMPOSITE = "Composite";
90
91     /**
92      The date pattern. By default, the pattern is set to
93      "'.'yyyy-MM-dd" meaning daily rollover.
94     */

95     private String JavaDoc datePattern = "'.'yyyy-MM-dd";
96
97     /** The actual formatted filename that is currently being written to
98          or will be the file transferred to on roll over
99          (based on staticLogFileName). */

100     private String JavaDoc scheduledFilename = null;
101
102     /** The timestamp when we shall next recompute the filename. */
103     private long nextCheck = System.currentTimeMillis () - 1;
104
105     /** Holds date of last roll over */
106     Date JavaDoc now = new Date JavaDoc();
107
108     SimpleDateFormat JavaDoc sdf;
109
110     /** Helper class to determine next rollover time */
111     RollingCalendar rc = new RollingCalendar();
112
113     /** Current period for roll overs */
114     int checkPeriod = TOP_OF_TROUBLE;
115
116     /** The default maximum file size is 10MB. */
117     protected long maxFileSize = 10*1024*1024;
118
119     /** There is zero backup files by default. */
120     protected int maxSizeRollBackups = 0;
121     /** How many sized based backups have been made so far */
122     protected int curSizeRollBackups = 0;
123
124     /** not yet implemented */
125     protected int maxTimeRollBackups = -1;
126     protected int curTimeRollBackups = 0;
127
128     /** By default newer files have lower numbers. (countDirection < 0)
129      * ie. log.1 is most recent, log.5 is the 5th backup, etc...
130      * countDirection > 0 does the opposite ie.
131      * log.1 is the first backup made, log.5 is the 5th backup made, etc.
132      * For infinite backups use countDirection > 0 to reduce rollOver costs.
133      */

134     protected int countDirection = -1;
135
136     /** Style of rolling to Use. BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) */
137     protected int rollingStyle = BY_COMPOSITE;
138     protected boolean rollDate = true;
139     protected boolean rollSize = true;
140
141     /** By default file.log is always the current file. Optionally
142      * file.log.yyyy-mm-dd for current formated datePattern can by the currently
143      * logging file (or file.log.curSizeRollBackup or even
144      * file.log.yyyy-mm-dd.curSizeRollBackup) This will make time based roll
145      * overs with a large number of backups much faster -- it won't have to
146      * rename all the backups!
147      */

148     protected boolean staticLogFileName = true;
149
150     /** FileName provided in configuration. Used for rolling properly */
151     protected String JavaDoc baseFileName;
152
153     /** The default constructor does nothing. */
154     public CompositeRollingAppender() {
155     }
156
157     /**
158      Instantiate a <code>CompositeRollingAppender</code> and open the
159      file designated by <code>filename</code>. The opened filename will
160      become the ouput destination for this appender.
161     */

162     public CompositeRollingAppender (Layout layout, String JavaDoc filename,
163                    String JavaDoc datePattern) throws IOException JavaDoc {
164         this(layout, filename, datePattern, true);
165     }
166
167     /**
168      Instantiate a CompositeRollingAppender and open the file designated by
169      <code>filename</code>. The opened filename will become the ouput
170      destination for this appender.
171
172      <p>If the <code>append</code> parameter is true, the file will be
173      appended to. Otherwise, the file desginated by
174      <code>filename</code> will be truncated before being opened.
175     */

176     public CompositeRollingAppender(Layout layout, String JavaDoc filename, boolean append)
177                                       throws IOException JavaDoc {
178         super(layout, filename, append);
179     }
180
181     /**
182      Instantiate a CompositeRollingAppender and open the file designated by
183      <code>filename</code>. The opened filename will become the ouput
184      destination for this appender.
185     */

186     public CompositeRollingAppender (Layout layout, String JavaDoc filename,
187                    String JavaDoc datePattern, boolean append) throws IOException JavaDoc {
188         super(layout, filename, append);
189         this.datePattern = datePattern;
190         activateOptions();
191     }
192     /**
193      Instantiate a CompositeRollingAppender and open the file designated by
194      <code>filename</code>. The opened filename will become the output
195      destination for this appender.
196
197      <p>The file will be appended to. DatePattern is default.
198     */

199     public CompositeRollingAppender(Layout layout, String JavaDoc filename) throws IOException JavaDoc {
200         super(layout, filename);
201     }
202
203     /**
204      The <b>DatePattern</b> takes a string in the same format as
205      expected by {@link SimpleDateFormat}. This options determines the
206      rollover schedule.
207     */

208     public void setDatePattern(String JavaDoc pattern) {
209         datePattern = pattern;
210     }
211
212     /** Returns the value of the <b>DatePattern</b> option. */
213     public String JavaDoc getDatePattern() {
214         return datePattern;
215     }
216
217     /**
218      Returns the value of the <b>maxSizeRollBackups</b> option.
219     */

220     public int getMaxSizeRollBackups() {
221         return maxSizeRollBackups;
222     }
223
224     /**
225      Get the maximum size that the output file is allowed to reach
226      before being rolled over to backup files.
227
228      @since 1.1
229     */

230     public long getMaximumFileSize() {
231         return maxFileSize;
232     }
233
234     /**
235      <p>Set the maximum number of backup files to keep around based on file size.
236
237      <p>The <b>MaxSizeRollBackups</b> option determines how many backup
238      files are kept before the oldest is erased. This option takes
239      an integer value. If set to zero, then there will be no
240      backup files and the log file will be truncated when it reaches
241      <code>MaxFileSize</code>. If a negative number is supplied then
242      no deletions will be made. Note that this could result in
243      very slow performance as a large number of files are rolled over unless
244      {@link #setCountDirection} up is used.
245
246      <p>The maximum applys to -each- time based group of files and -not- the total.
247      Using a daily roll the maximum total files would be (#days run) * (maxSizeRollBackups)
248
249     */

250     public void setMaxSizeRollBackups(int maxBackups) {
251         maxSizeRollBackups = maxBackups;
252     }
253
254     /**
255      Set the maximum size that the output file is allowed to reach
256      before being rolled over to backup files.
257
258      <p>This method is equivalent to {@link #setMaxFileSize} except
259      that it is required for differentiating the setter taking a
260      <code>long</code> argument from the setter taking a
261      <code>String</code> argument by the JavaBeans {@link
262      java.beans.Introspector Introspector}.
263
264      @see #setMaxFileSize(String)
265     */

266     public void setMaxFileSize(long maxFileSize) {
267        this.maxFileSize = maxFileSize;
268     }
269
270     /**
271      Set the maximum size that the output file is allowed to reach
272      before being rolled over to backup files.
273
274      <p>This method is equivalent to {@link #setMaxFileSize} except
275      that it is required for differentiating the setter taking a
276      <code>long</code> argument from the setter taking a
277      <code>String</code> argument by the JavaBeans {@link
278      java.beans.Introspector Introspector}.
279
280      @see #setMaxFileSize(String)
281     */

282     public void setMaximumFileSize(long maxFileSize) {
283         this.maxFileSize = maxFileSize;
284     }
285
286     /**
287      Set the maximum size that the output file is allowed to reach
288      before being rolled over to backup files.
289
290      <p>In configuration files, the <b>MaxFileSize</b> option takes an
291      long integer in the range 0 - 2^63. You can specify the value
292      with the suffixes "KB", "MB" or "GB" so that the integer is
293      interpreted being expressed respectively in kilobytes, megabytes
294      or gigabytes. For example, the value "10KB" will be interpreted
295      as 10240.
296     */

297     public void setMaxFileSize(String JavaDoc value) {
298         maxFileSize = OptionConverter.toFileSize(value, maxFileSize + 1);
299     }
300
301     protected void setQWForFiles(Writer writer) {
302         qw = new CountingQuietWriter(writer, errorHandler);
303     }
304
305     //Taken verbatum from DailyRollingFileAppender
306
int computeCheckPeriod() {
307         RollingCalendar c = new RollingCalendar();
308         // set sate to 1970-01-01 00:00:00 GMT
309
Date JavaDoc epoch = new Date JavaDoc(0);
310         if(datePattern != null) {
311             for(int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++) {
312                 String JavaDoc r0 = sdf.format(epoch);
313                 c.setType(i);
314                 Date JavaDoc next = new Date JavaDoc(c.getNextCheckMillis(epoch));
315                 String JavaDoc r1 = sdf.format(next);
316                 //LogLog.debug("Type = "+i+", r0 = "+r0+", r1 = "+r1);
317
if(r0 != null && r1 != null && !r0.equals(r1)) {
318                     return i;
319                 }
320             }
321         }
322         return TOP_OF_TROUBLE; // Deliberately head for trouble...
323
}
324
325     //Now for the new stuff
326
/**
327      * Handles append time behavior for CompositeRollingAppender. This checks
328      * if a roll over either by date (checked first) or time (checked second)
329      * is need and then appends to the file last.
330     */

331     protected void subAppend(LoggingEvent event) {
332
333         if (rollDate) {
334             long n = System.currentTimeMillis();
335             if (n >= nextCheck) {
336                 now.setTime(n);
337                 nextCheck = rc.getNextCheckMillis(now);
338
339                 rollOverTime();
340             }
341         }
342
343         if (rollSize) {
344             if ((fileName != null) && ((CountingQuietWriter) qw).getCount() >= maxFileSize) {
345                 rollOverSize();
346             }
347         }
348
349         super.subAppend(event);
350     }
351
352     public void setFile(String JavaDoc file)
353     {
354         baseFileName = file.trim();
355         fileName = file.trim();
356     }
357
358     /**
359      * Creates and opens the file for logging. If <code>staticLogFileName</code>
360      * is false then the fully qualified name is determined and used.
361      */

362     public synchronized void setFile(String JavaDoc fileName, boolean append) throws IOException JavaDoc {
363         if (!staticLogFileName) {
364             scheduledFilename = fileName = fileName.trim() + sdf.format(now);
365             if (countDirection > 0) {
366                 scheduledFilename = fileName = fileName + '.' + (++curSizeRollBackups);
367             }
368         }
369
370         super.setFile(fileName, append);
371         if(append) {
372           File JavaDoc f = new File JavaDoc(fileName);
373           ((CountingQuietWriter) qw).setCount(f.length());
374         }
375     }
376
377     public int getCountDirection() {
378         return countDirection;
379     }
380
381     public void setCountDirection(int direction) {
382         countDirection = direction;
383     }
384
385     public int getRollingStyle () {
386         return rollingStyle;
387     }
388
389     public void setRollingStyle(int style) {
390         rollingStyle = style;
391         switch (rollingStyle) {
392             case BY_SIZE:
393                  rollDate = false;
394                  rollSize = true;
395                  break;
396             case BY_DATE:
397                  rollDate = true;
398                  rollSize = false;
399                  break;
400             case BY_COMPOSITE:
401                  rollDate = true;
402                  rollSize = true;
403                  break;
404             default:
405                 errorHandler.error("Invalid rolling Style, use 1 (by size only), 2 (by date only) or 3 (both)");
406         }
407     }
408
409 /*
410     public void setRollingStyle(String style) {
411         if (style == S_BY_SIZE) {
412             rollingStyle = BY_SIZE;
413         }
414         else if (style == S_BY_DATE) {
415             rollingStyle = BY_DATE;
416         }
417         else if (style == S_BY_COMPOSITE) {
418             rollingStyle = BY_COMPOSITE;
419         }
420     }
421 */

422     public boolean getStaticLogFileName() {
423         return staticLogFileName;
424     }
425
426     public void setStaticLogFileName(boolean s) {
427         staticLogFileName = s;
428     }
429
430     public void setStaticLogFileName(String JavaDoc value) {
431         setStaticLogFileName(OptionConverter.toBoolean(value, true));
432     }
433
434     /**
435      * Initializes based on exisiting conditions at time of <code>
436      * activateOptions</code>. The following is done:<br>
437      * <br>
438      * A) determine curSizeRollBackups<br>
439      * B) determine curTimeRollBackups (not implemented)<br>
440      * C) initiates a roll over if needed for crossing a date boundary since
441      * the last run.
442      */

443     protected void existingInit() {
444
445         curSizeRollBackups = 0;
446         curTimeRollBackups = 0;
447
448         //part A starts here
449
String JavaDoc filter;
450         if (staticLogFileName || !rollDate) {
451             filter = baseFileName + ".*";
452         }
453         else {
454             filter = scheduledFilename + ".*";
455         }
456
457         File JavaDoc f = new File JavaDoc(baseFileName);
458         f = f.getParentFile();
459         if (f == null)
460            f = new File JavaDoc(".");
461
462         LogLog.debug("Searching for existing files in: " + f);
463         String JavaDoc[] files = f.list();
464
465         if (files != null) {
466             for (int i = 0; i < files.length; i++) {
467                 if (!files[i].startsWith(baseFileName))
468                    continue;
469
470                 int index = files[i].lastIndexOf(".");
471
472                 if (staticLogFileName) {
473                    int endLength = files[i].length() - index;
474                    if (baseFileName.length() + endLength != files[i].length()) {
475                        //file is probably scheduledFilename + .x so I don't care
476
continue;
477                    }
478                 }
479
480                 try {
481                     int backup = Integer.parseInt(files[i].substring(index + 1, files[i].length()));
482                     LogLog.debug("From file: " + files[i] + " -> " + backup);
483                     if (backup > curSizeRollBackups)
484                        curSizeRollBackups = backup;
485                 }
486                 catch (Exception JavaDoc e) {
487                     //this happens when file.log -> file.log.yyyy-mm-dd which is normal
488
//when staticLogFileName == false
489
LogLog.debug("Encountered a backup file not ending in .x " + files[i]);
490                 }
491             }
492         }
493         LogLog.debug("curSizeRollBackups starts at: " + curSizeRollBackups);
494         //part A ends here
495

496         //part B not yet implemented
497

498         //part C
499
if (staticLogFileName && rollDate) {
500             File JavaDoc old = new File JavaDoc(baseFileName);
501             if (old.exists()) {
502                 Date JavaDoc last = new Date JavaDoc(old.lastModified());
503                 if (!(sdf.format(last).equals(sdf.format(now)))) {
504                     scheduledFilename = baseFileName + sdf.format(last);
505                     LogLog.debug("Initial roll over to: " + scheduledFilename);
506                     rollOverTime();
507                 }
508             }
509         }
510         LogLog.debug("curSizeRollBackups after rollOver at: " + curSizeRollBackups);
511         //part C ends here
512

513     }
514
515     /**
516      * Sets initial conditions including date/time roll over information, first check,
517      * scheduledFilename, and calls <code>existingInit</code> to initialize
518      * the current # of backups.
519      */

520     public void activateOptions() {
521
522         //REMOVE removed rollDate from boolean to enable Alex's change
523
if(datePattern != null) {
524             now.setTime(System.currentTimeMillis());
525             sdf = new SimpleDateFormat JavaDoc(datePattern);
526             int type = computeCheckPeriod();
527             //printPeriodicity(type);
528
rc.setType(type);
529             //next line added as this removes the name check in rollOver
530
nextCheck = rc.getNextCheckMillis(now);
531         } else {
532             if (rollDate)
533                 LogLog.error("Either DatePattern or rollingStyle options are not set for ["+
534                   name+"].");
535         }
536
537         existingInit();
538
539         super.activateOptions();
540
541         if (rollDate && fileName != null && scheduledFilename == null)
542             scheduledFilename = fileName + sdf.format(now);
543     }
544
545     /**
546      Rollover the file(s) to date/time tagged file(s).
547      Opens the new file (through setFile) and resets curSizeRollBackups.
548     */

549     protected void rollOverTime() {
550
551         curTimeRollBackups++;
552
553         //delete the old stuff here
554

555         if (staticLogFileName) {
556             /* Compute filename, but only if datePattern is specified */
557             if (datePattern == null) {
558                 errorHandler.error("Missing DatePattern option in rollOver().");
559                 return;
560             }
561
562             //is the new file name equivalent to the 'current' one
563
//something has gone wrong if we hit this -- we should only
564
//roll over if the new file will be different from the old
565
String JavaDoc dateFormat = sdf.format(now);
566             if (scheduledFilename.equals(fileName + dateFormat)) {
567                 errorHandler.error("Compare " + scheduledFilename + " : " + fileName + dateFormat);
568                 return;
569             }
570
571             // close current file, and rename it to datedFilename
572
this.closeFile();
573
574             //we may have to roll over a large number of backups here
575
String JavaDoc from, to;
576             for (int i = 1; i <= curSizeRollBackups; i++) {
577                 from = fileName + '.' + i;
578                 to = scheduledFilename + '.' + i;
579                 rollFile(from, to);
580             }
581
582             rollFile(fileName, scheduledFilename);
583         }
584
585         try {
586             // This will also close the file. This is OK since multiple
587
// close operations are safe.
588
curSizeRollBackups = 0; //We're cleared out the old date and are ready for the new
589

590             //new scheduled name
591
scheduledFilename = fileName + sdf.format(now);
592             this.setFile(baseFileName, false);
593         }
594         catch(IOException JavaDoc e) {
595             errorHandler.error("setFile("+fileName+", false) call failed.");
596         }
597
598     }
599
600     /** Renames file <code>from</code> to file <code>to</code>. It
601      * also checks for existence of target file and deletes if it does.
602      */

603     protected static void rollFile(String JavaDoc from, String JavaDoc to) {
604         File JavaDoc target = new File JavaDoc(to);
605         if (target.exists()) {
606             LogLog.debug("deleting existing target file: " + target);
607             target.delete();
608         }
609
610         File JavaDoc file = new File JavaDoc(from);
611         file.renameTo(target);
612         LogLog.debug(from +" -> "+ to);
613     }
614
615     /** Delete's the specified file if it exists */
616     protected static void deleteFile(String JavaDoc fileName) {
617         File JavaDoc file = new File JavaDoc(fileName);
618         if (file.exists()) {
619            file.delete();
620         }
621     }
622
623     /**
624      Implements roll overs base on file size.
625
626      <p>If the maximum number of size based backups is reached
627      (<code>curSizeRollBackups == maxSizeRollBackups</code) then the oldest
628      file is deleted -- it's index determined by the sign of countDirection.<br>
629      If <code>countDirection</code> < 0, then files
630      {<code>File.1</code>, ..., <code>File.curSizeRollBackups -1</code>}
631      are renamed to {<code>File.2</code>, ...,
632      <code>File.curSizeRollBackups</code>}. Moreover, <code>File</code> is
633      renamed <code>File.1</code> and closed.<br>
634
635      A new file is created to receive further log output.
636
637      <p>If <code>maxSizeRollBackups</code> is equal to zero, then the
638      <code>File</code> is truncated with no backup files created.
639
640      <p>If <code>maxSizeRollBackups</code> < 0, then <code>File</code> is
641      renamed if needed and no files are deleted.
642     */

643
644     // synchronization not necessary since doAppend is alreasy synched
645
protected void rollOverSize() {
646         File JavaDoc file;
647
648         this.closeFile(); // keep windows happy.
649

650         LogLog.debug("rolling over count=" + ((CountingQuietWriter) qw).getCount());
651         LogLog.debug("maxSizeRollBackups = " + maxSizeRollBackups);
652         LogLog.debug("curSizeRollBackups = " + curSizeRollBackups);
653         LogLog.debug("countDirection = " + countDirection);
654
655         // If maxBackups <= 0, then there is no file renaming to be done.
656
if (maxSizeRollBackups != 0) {
657
658             if (countDirection < 0) {
659                 // Delete the oldest file, to keep Windows happy.
660
if (curSizeRollBackups == maxSizeRollBackups) {
661                     deleteFile(fileName + '.' + maxSizeRollBackups);
662                     curSizeRollBackups--;
663                 }
664
665                 // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
666
for (int i = curSizeRollBackups; i >= 1; i--) {
667                     rollFile((fileName + "." + i), (fileName + '.' + (i + 1)));
668                 }
669
670                 curSizeRollBackups++;
671                 // Rename fileName to fileName.1
672
rollFile(fileName, fileName + ".1");
673
674             } //REMOVE This code branching for Alexander Cerna's request
675
else if (countDirection == 0) {
676                 //rollFile based on date pattern
677
curSizeRollBackups++;
678                 now.setTime(System.currentTimeMillis());
679                 scheduledFilename = fileName + sdf.format(now);
680                 rollFile(fileName, scheduledFilename);
681             }
682             else { //countDirection > 0
683
if (curSizeRollBackups >= maxSizeRollBackups && maxSizeRollBackups > 0) {
684                     //delete the first and keep counting up.
685
int oldestFileIndex = curSizeRollBackups - maxSizeRollBackups + 1;
686                     deleteFile(fileName + '.' + oldestFileIndex);
687                 }
688
689                 if (staticLogFileName) {
690                     curSizeRollBackups++;
691                     rollFile(fileName, fileName + '.' + curSizeRollBackups);
692                 }
693             }
694         }
695
696         try {
697             // This will also close the file. This is OK since multiple
698
// close operations are safe.
699
this.setFile(baseFileName, false);
700         }
701         catch(IOException JavaDoc e) {
702             LogLog.error("setFile("+fileName+", false) call failed.", e);
703         }
704     }
705
706 }
Popular Tags