logName = prefix + suffix;
maxSize = cfg.getLong("maxsize",DEF_MAXSIZE);
try {
openLogFile();
} catch (IOException e) {
throw new ConfigurationException ("error opening file: " + logName,
e);
}
sleepTime = cfg.getInt("window", DEF_WIN);
if (sleepTime <= 0)
sleepTime = DEF_WIN;
sleepTime*=1000;
DateFormat fmt = new SimpleDateFormat(cfg.get("date-format",DEF_DATE_FMT));
setDateFmt(fmt);
setLastDate(fmt.format(new Date()));
Date time;
try {
time = new SimpleDateFormat("HH:mm:ss").parse(cfg.get("first-rotate-time", "00:00:00"));
} catch (ParseException ex) {
throw new ConfigurationException("Bad 'first-rotate-time' format " +
"expected HH(0-23):mm:ss ",ex);
}
String strDate = cfg.get("first-rotate-date",null);
//calculate the first execution time
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MILLISECOND,0);
Calendar calTemp = Calendar.getInstance();
calTemp.setTime(time);
cal.set(Calendar.SECOND,calTemp.get(Calendar.SECOND));
cal.set(Calendar.MINUTE,calTemp.get(Calendar.MINUTE));
cal.set(Calendar.HOUR_OF_DAY,calTemp.get(Calendar.HOUR_OF_DAY));
if (strDate != null) {
Date date;
try {
date = new SimpleDateFormat("yyyy-MM-dd").parse(strDate);
} catch (ParseException ex) {
throw new ConfigurationException("Bad 'first-rotate-date' " +
"format, expected (yyyy-MM-dd)", ex);
}
calTemp.setTime(date);
cal.set(calTemp.get(Calendar.YEAR), calTemp.get(Calendar.MONTH),
calTemp.get(Calendar.DATE));