@SuppressWarnings("unchecked") public static synchronized void syncLogs( String logLocation, TaskAttemptID taskid, boolean isCleanup, boolean segmented) throws IOException { System.out.flush(); System.err.flush(); Enumeration<Logger> allLoggers = LogManager.getCurrentLoggers(); while (allLoggers.hasMoreElements()) { Logger l = allLoggers.nextElement(); Enumeration<Appender> allAppenders = l.getAllAppenders(); while (allAppenders.hasMoreElements()) { Appender a = allAppenders.nextElement(); if (a instanceof TaskLogAppender) { ((TaskLogAppender) a).flush(); } } } if (currentTaskid == null) { currentTaskid = taskid; } // set start and end for (LogName logName : LOGS_TRACKED_BY_INDEX_FILES) { if (currentTaskid != taskid) { // Set start = current-end logLengths.get(logName)[0] = Long.valueOf(new File(logLocation, logName.toString()).length()); } // Set current end logLengths.get(logName)[1] = (segmented ? (Long.valueOf(new File(logLocation, logName.toString()).length())) : -1); } if (currentTaskid != taskid) { if (currentTaskid != null) { LOG.info( "Starting logging for a new task " + taskid + " in the same JVM as that of the first task " + logLocation); } currentTaskid = taskid; } writeToIndexFile(logLocation, taskid, isCleanup, logLengths); }