Code example for StreamHandler

Methods: setFormatter

0
 
	public static void main(String[] args) {
		 
		Logger logger = Logger.getLogger(SingleLineFormatter.class.getPackage().getName());
		 
  	Handler handler = new StreamHandler();
  	Formatter formatter = new SingleLineFormatter();
  	handler.setFormatter(formatter);
  	logger.addHandler(handler);
 
		// Log a few message at different severity levels 
		logger.severe("severe message");
		logger.warning("warning message");
		logger.info("info message");
		logger.config("config message");
		logger.fine("fine message");
		logger.finer("finer message");
		logger.finest("finest message");
	} 
}