private File getFile() { if (outFile == null || dateUnit != DateUtil.getDateUnit()) { String filename = FILE_PREFIX + "-" + DateUtil.yyyymmdd()+ ".log"; outFile = new File(DIRECTORY, filename); File parentDir = new File(DIRECTORY); if (parentDir.exists() == false) { parentDir.mkdirs(); } } return outFile; }
public String error(XLogPack p) { return TextRD.getString(DateUtil.yyyymmdd(p.endTime), TextTypes.ERROR, p.error); }
public String service(XLogPack p) { return TextRD.getString(DateUtil.yyyymmdd(p.endTime), TextTypes.SERVICE, p.service); }
static public String getDBPath(long time, String objName){ StringBuilder buffer = new StringBuilder(); buffer.append(DBCtr.getRootPath()); buffer.append('/').append(DateUtil.yyyymmdd(time)).append('/').append(objName).append('/').append(DateUtil.getHour(time)); return buffer.toString(); }
private static synchronized void openFile() throws IOException { if (pw == null) { lastDataUnit = DateUtil.getDateUnit(); lastDir = conf.log_dir; lastFileRotation = conf.log_rotation_enalbed; new File(lastDir).mkdirs(); if (conf.log_rotation_enalbed) { FileWriter fw = new FileWriter(new File(conf.log_dir, "agent-" + DateUtil.yyyymmdd() + ".log"), true); pw = new PrintWriter(fw); } else { pw = new PrintWriter(new File(conf.log_dir, "agent.log")); } lastDataUnit = DateUtil.getDateUnit(); } }
private static synchronized void openFile(String prefix) throws IOException { if (pw == null && StringUtil.isEmpty(conf.log_dir) == false) { File root = new File(conf.log_dir); if (root.canWrite() == false) { root.mkdirs(); } if (root.canWrite() == false) { return; } if (conf.log_rotation_enabled) { File file = new File(conf.log_dir, "scouter-" + prefix + "-" + DateUtil.yyyymmdd() + ".log"); FileWriter fw = new FileWriter(file, true); pw = new PrintWriter(fw); logfile = file; } else { File file = new File(conf.log_dir, "scouter-" + prefix + ".log"); pw = new PrintWriter(new FileWriter(file, true)); logfile = file; } } }
private static synchronized void openFile(String prefix) throws IOException { if (pw == null && StringUtil.isEmpty(conf.log_dir) == false) { File root = new File(conf.log_dir); if (root.canWrite() == false) { root.mkdirs(); } if (root.canWrite() == false) { return; } if (conf.log_rotation_enabled) { File file = new File(conf.log_dir, "scouter-" + prefix + "-" + DateUtil.yyyymmdd() + ".log"); FileWriter fw = new FileWriter(file, true); pw = new PrintWriter(fw); logfile = file; } else { File file = new File(conf.log_dir, "scouter-" + prefix + ".log"); pw = new PrintWriter(new FileWriter(file, true)); logfile = file; } } }
private static synchronized void openFile(String prefix) throws IOException { if (pw == null && StringUtil.isEmpty(conf.log_dir) == false) { File root = new File(conf.log_dir); if (root.canWrite() == false) { root.mkdirs(); } if (root.canWrite() == false) { return; } String name = prefix + ((conf.batch_id == null)?"batch":conf.batch_id + "_" + SysJMX.getProcessPID()); if (conf.log_rotation_enabled) { File file = new File(conf.log_dir, "scouter-" + name + "-" + DateUtil.yyyymmdd() + ".log"); FileWriter fw = new FileWriter(file, true); pw = new PrintWriter(fw); logfile = file; } else { File file = new File(conf.log_dir, "scouter-" + name + ".log"); pw = new PrintWriter(new FileWriter(file, true)); logfile = file; } } }
long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); if (nowUnit - fileUnit > conf.log_keep_days) {
long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); if (nowUnit - fileUnit > conf.log_keep_days) {
protected static void clearOldLog() { if (conf.log_rotation_enalbed == false) return; if (conf.log_keep_days <= 0) return; long nowUnit = DateUtil.getDateUnit(); File dir = new File(conf.log_dir); File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) continue; String name = files[i].getName(); if (name.startsWith("agent-") == false) continue; int x = name.lastIndexOf('.'); if (x < 0) continue; String date = name.substring("agent-".length(), x); if (date.length() != 8) continue; try { long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) { files[i].delete(); } } catch (Exception e) { } } }
public String getText(long date, int hash, int serverId) { if (hash == 0) { return null; } String value = getCachedText(hash); if (value != null) { return value; } ArrayList list = new ArrayList(); list.add(hash); String yyyymmdd = DateUtil.yyyymmdd(date); load(yyyymmdd, list, serverId); return getCachedText(hash); }
long d = DateUtil.yyyymmdd(date); long fileUnit = DateUtil.getDateUnit(d); if (nowUnit - fileUnit > DateUtil.MILLIS_PER_DAY * conf.log_keep_days) {
time = DateUtil.yyyymmdd("20101123");
time = DateUtil.yyyymmdd("20101123");
time = DateUtil.yyyymmdd("20101123");
time = DateUtil.yyyymmdd("20101123");
time = DateUtil.yyyymmdd("20101123");
String yyyymmdd = DateUtil.yyyymmdd(time); String hhmmss = FormatUtil.print(new Date(time), "HHmmss"); String fName = yyyymmdd + "-" + hhmmss + ((MapPack) param).getText("fName").replaceAll("/", "_") + fileExt;
String yyyymmdd = DateUtil.yyyymmdd(time); String hhmmss = FormatUtil.print(new Date(time), "HHmmss"); String fName = yyyymmdd + "-" + hhmmss + ((MapPack) param).getText("fName").replaceAll("/", "_") + fileExt;