Code example for FileHandler

Methods: setFormatter

0
		File file = new File("HangmanLogFile.log");
		file.delete();
		try { 
 
			// This block configure the logger with handler and formatter 
			fh = new FileHandler("HangmanLogFile.log", true);
 
			logger.addHandler(fh);
			logger.setLevel(Level.ALL);
			HangmanFormatter formatter = new HangmanFormatter();
			fh.setFormatter(formatter);
 
			// the following statement is used to log any messages 
			// logger.log(Level.FINE,"My first log"); 
 
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} 
		new Screen();