/** Initialize the log. */
  public void init() throws IOException {
    long now = CurrentTime.getExactTime();

    // server/0263
    // _nextRolloverCheckTime = now + _rolloverCheckPeriod;

    Path path = getPath();

    if (path != null) {
      path.getParent().mkdirs();

      _rolloverPrefix = path.getTail();

      long lastModified = path.getLastModified();

      if (lastModified <= 0 || now < lastModified) {
        lastModified = now;
      }

      // _calendar.setGMTTime(lastModified);

      _nextPeriodEnd = nextRolloverTime(lastModified);
    } else {
      _nextPeriodEnd = nextRolloverTime(now);
    }

    if (_archiveFormat != null || getRolloverPeriod() <= 0) {
    } else if (_rolloverCron != null) _archiveFormat = _rolloverPrefix + ".%Y%m%d.%H";
    else if (getRolloverPeriod() % DAY == 0) _archiveFormat = _rolloverPrefix + ".%Y%m%d";
    else if (getRolloverPeriod() % HOUR == 0) _archiveFormat = _rolloverPrefix + ".%Y%m%d.%H";
    else _archiveFormat = _rolloverPrefix + ".%Y%m%d.%H%M";

    _isInit = true;

    _rolloverListener.requeue(_rolloverAlarm);
    rollover();
  }
Esempio n. 2
0
 public long getMTime(Env env) {
   return _path.getLastModified() / 1000;
 }