Ejemplo n.º 1
0
 int computeCheckPeriod() {
   CalendarRollingCalendar rollingCalendar =
       new CalendarRollingCalendar(gmtTimeZone, Locale.ENGLISH);
   // set sate to 1970-01-01 00:00:00 GMT
   Date epoch = new Date(0);
   if (datePattern != null) {
     for (int i = TOP_OF_MINUTE; i <= TOP_OF_MONTH; i++) {
       SimpleDateFormat simpleDateFormat = new SimpleDateFormat(datePattern);
       simpleDateFormat.setTimeZone(gmtTimeZone); // do all date
       // formatting in GMT
       String r0 = simpleDateFormat.format(epoch);
       rollingCalendar.setType(i);
       Date next = new Date(rollingCalendar.getNextCheckMillis(epoch));
       String r1 = simpleDateFormat.format(next);
       // logger.info("Type = "+i+", r0 = "+r0+", r1 = "+r1);
       if (r0 != null && r1 != null && !r0.equals(r1)) {
         return i;
       }
     }
   }
   return TOP_OF_TROUBLE; // Deliberately head for trouble...
 }
Ejemplo n.º 2
0
  public void activateOptions() {
    if (datePattern != null && name != null) {
      now.setTime(System.currentTimeMillis());
      sdf = new SimpleDateFormat(datePattern);
      int type = computeCheckPeriod();
      printPeriodicity(type);
      rc.setType(type);
      fileName = this.buildLogFilePathAnddeleteTimeoutFile(-1);
      File file = new File(fileName);
      // Strfilename = String.format("[%s]%s_%d",
      // sdf.format(now),Strfilename,1);

      scheduledDate = sdf.format(new Date(file.lastModified()));
      /*
       * scheduledFilename = String.format("[%s]%s.%s", sdf.format(new
       * Date( file.lastModified())), name, extname);
       */
      // Date(file.lastModified()));
    } else {
      LogLog.error("Either File or DatePattern options are not set for appender [" + name + "].");
    }
    super.activateOptions();
  }