@Test public void getTaskLogHome() { Path taskLogHome = Paths.get(TaskLogHome.getTaskLogHome()); assertTrue(taskLogHome.endsWith(Paths.get("test", "log", "tasks"))); Path file = taskLogHome.resolve("temp.log"); assertFalse("temp file was not deleted", Files.exists(file)); }
@Nullable public static String getTaskLogHome() { LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); Appender<ILoggingEvent> appender = loggerContext.getLogger(ROOT_LOGGER_NAME).getAppender("tasklogfile"); if (!(appender instanceof SiftingAppender)) { log.error("Could not find a Logback SiftingAppender named 'tasklogfile' in the logback configuration. " + "Please check that the 'tasklogfile' appender exists in logback.xml"); return null; } SiftingAppender siftingAppender = (SiftingAppender) appender; FileAppender<ILoggingEvent> tempFileAppender = (FileAppender<ILoggingEvent>) siftingAppender.getAppenderTracker() .getOrCreate("temp", 0L); File file = new File(tempFileAppender.getFile()); String taskLogsFolder = file.getParent(); tempFileAppender.stop(); FileUtils.deleteQuietly(file); return taskLogsFolder; }
TaskLogHome { @Nullable public static String getTaskLogHome() { LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); Appender<ILoggingEvent> appender = loggerContext.getLogger(ROOT_LOGGER_NAME).getAppender("tasklogfile"); if (!(appender instanceof SiftingAppender)) { log.error("Could not find a Logback SiftingAppender named 'tasklogfile' in the logback configuration. " + "Please check that the 'tasklogfile' appender exists in logback.xml"); return null; } SiftingAppender siftingAppender = (SiftingAppender) appender; FileAppender<ILoggingEvent> tempFileAppender = (FileAppender<ILoggingEvent>) siftingAppender.getAppenderTracker() .getOrCreate("temp", 0L); File file = new File(tempFileAppender.getFile()); String taskLogsFolder = file.getParent(); tempFileAppender.stop(); FileUtils.deleteQuietly(file); return taskLogsFolder; } }
TaskLogHome { @Nullable public static String getTaskLogHome() { LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); Appender<ILoggingEvent> appender = loggerContext.getLogger(ROOT_LOGGER_NAME).getAppender("tasklogfile"); if (!(appender instanceof SiftingAppender)) { log.error("Could not find a Logback SiftingAppender named 'tasklogfile' in the logback configuration. " + "Please check that the 'tasklogfile' appender exists in logback.xml"); return null; } SiftingAppender siftingAppender = (SiftingAppender) appender; FileAppender<ILoggingEvent> tempFileAppender = (FileAppender<ILoggingEvent>) siftingAppender.getAppenderTracker() .getOrCreate("temp", 0L); File file = new File(tempFileAppender.getFile()); String taskLogsFolder = file.getParent(); tempFileAppender.stop(); FileUtils.deleteQuietly(file); return taskLogsFolder; } private  TaskLogHome(); }
TaskLogHome { @Nullable public static String getTaskLogHome() { LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); Appender<ILoggingEvent> appender = loggerContext.getLogger(ROOT_LOGGER_NAME).getAppender("tasklogfile"); if (!(appender instanceof SiftingAppender)) { log.error("Could not find a Logback SiftingAppender named 'tasklogfile' in the logback configuration. " + "Please check that the 'tasklogfile' appender exists in logback.xml"); return null; } SiftingAppender siftingAppender = (SiftingAppender) appender; FileAppender<ILoggingEvent> tempFileAppender = (FileAppender<ILoggingEvent>) siftingAppender.getAppenderTracker() .getOrCreate("temp", 0L); File file = new File(tempFileAppender.getFile()); String taskLogsFolder = file.getParent(); tempFileAppender.stop(); FileUtils.deleteQuietly(file); return taskLogsFolder; } private  TaskLogHome(); @Nullable static String getTaskLogHome(); }
TaskLogHome { @Nullable public static String getTaskLogHome() { LoggerContext loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory(); Appender<ILoggingEvent> appender = loggerContext.getLogger(ROOT_LOGGER_NAME).getAppender("tasklogfile"); if (!(appender instanceof SiftingAppender)) { log.error("Could not find a Logback SiftingAppender named 'tasklogfile' in the logback configuration. " + "Please check that the 'tasklogfile' appender exists in logback.xml"); return null; } SiftingAppender siftingAppender = (SiftingAppender) appender; FileAppender<ILoggingEvent> tempFileAppender = (FileAppender<ILoggingEvent>) siftingAppender.getAppenderTracker() .getOrCreate("temp", 0L); File file = new File(tempFileAppender.getFile()); String taskLogsFolder = file.getParent(); tempFileAppender.stop(); FileUtils.deleteQuietly(file); return taskLogsFolder; } private  TaskLogHome(); @Nullable static String getTaskLogHome();  }