final void setupOutputDirectory(OutputDirectoryHierarchy controlerIO) { this.controlerIO = controlerIO; OutputDirectoryLogging.initLogging(this.getControlerIO()); // logging needs to be early }
/** * Call this method to create 2 log4j logfiles in the output directory specified as parameter. * The first logfile contains all messages the second only those above log Level.WARN (Priority.WARN). * After the end of the programm run it is strongly recommended to close the file logger by calling * the method closeOutputDirLogging(). * * @param outputDirectory the outputdirectory to create the files, whithout seperator at the end. * @throws IOException * @see IOUtils#closeOutputDirLogging() * @author dgrether */ public static void initLoggingWithOutputDirectory(final String outputDirectory) throws IOException { if (collectLogMessagesAppender != null) { Logger.getRootLogger().removeAppender(collectLogMessagesAppender); } String logfilename = outputDirectory + System.getProperty("file.separator") + LOGFILE; String warnlogfilename = outputDirectory + System.getProperty("file.separator") + WARNLOGFILE; initLogging(logfilename, warnlogfilename); }
/** * Initializes log4j to write log output to files in output directory. * @param outputDirectoryHierarchy TODO */ public final static void initLogging(OutputDirectoryHierarchy outputDirectoryHierarchy) { if (collectLogMessagesAppender != null) { Logger.getRootLogger().removeAppender(collectLogMessagesAppender); } try { String outputFilename = outputDirectoryHierarchy.getOutputFilename(LOGFILE); String warnLogfileName = outputDirectoryHierarchy.getOutputFilename(WARNLOGFILE); initLogging(outputFilename, warnLogfileName); } catch (IOException e) { log.error("Cannot create logfiles: " + e.getMessage()); e.printStackTrace(); } }