Setting the Formatter of a Logger Handler
import java.util.logging.FileHandler; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; public class Main{ public static void main(String[] argv) throws Exception{ Logger logger = Logger.getLogger("com.mycompany"); FileHandler fh = new FileHandler("mylog.txt"); fh.setFormatter(new SimpleFormatter()); logger.addHandler(fh); // fh = new FileHandler("mylog.xml"); // fh.setFormatter(new XMLFormatter()); // logger.addHandler(fh); // Log a few messages logger.severe("my severe message"); logger.warning("my warning message"); logger.info("my info message"); logger.config("my config message"); logger.fine("my fine message"); logger.finer("my finer message"); logger.finest("my finest message"); } }