/** * Gets the last lines from a suite log. * @param suite the suite to extract the log from * @param lineQty the number of lines to retrieve * @return string representation of log last lines * @throws IOException problem getting lines */ @SuppressWarnings("nls") protected final String getLogTail(final JobSuite suite, final int lineQty) throws IOException { StringBuffer logTail = new StringBuffer(); String[] lines = IOUtil.tail( suite.getLogManager().getLog(suite.getId()), lineQty); if (lines.length == 0) { logTail.append("*** No log found. ***\n"); } else { for (int i = 0; i < lines.length; i++) { String line = lines[i]; logTail.append(line); logTail.append('\n'); } } return logTail.toString(); } }
private void writeJobSuiteIndex(JobSuiteStatusSnapshot statusTree) throws IOException { File indexFile = getSuiteIndexFile(); StringWriter out = new StringWriter(); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); out.write("<suite-index>"); //--- Log Manager --- out.flush(); getLogManager().saveToXML(out); //--- JobStatusSerializer --- out.flush(); getJobStatusStore().saveToXML(out); //--- Job Status --- writeJobId(out, statusTree, statusTree.getRoot()); out.write("</suite-index>"); out.flush(); // Using RandomAccessFile since evidence has shown it is better at // dealing with files/locks in a way that cause less/no errors. try (RandomAccessFile ras = new RandomAccessFile(indexFile, "rwd"); FileChannel channel = ras.getChannel(); FileLock lock = channel.lock()) { ras.writeUTF(out.toString()); } }
getLogManager().backup(getId(), backupDate);
Appender appender = getLogManager().createAppender(getId()); appender.setLayout(new ThreadSafeLayout(appender.getLayout()));