Code example for FileHandler

Methods: setFormatter

0
 
	static public void setup() throws IOException { 
		// Create Logger 
		Logger logger = Logger.getLogger("");
		logger.setLevel(Level.INFO);
		fileTxt = new FileHandler("Logging.txt");
		fileHTML = new FileHandler("Logging.html");
 
		// Create txt Formatter 
		formatterTxt = new SimpleFormatter();
		fileTxt.setFormatter(formatterTxt);
		logger.addHandler(fileTxt);
 
		// Create HTML Formatter 
		formatterHTML = new HtmlFormatter();
		fileHTML.setFormatter(formatterHTML);
		logger.addHandler(fileHTML);
		 
		// Create console handler 
		logger.addHandler(new ConsoleHandler());