new SimpleFormatter() : SimpleFormatter « java.util.logging « Java by API






new SimpleFormatter()

  


import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

public class Main{
  private static Logger logger = Logger.getLogger("LogToFile2");

  public static void main(String[] args) throws Exception {
    FileHandler logFile = new FileHandler("LogToFile2.txt");
    logFile.setFormatter(new SimpleFormatter());
    logger.addHandler(logFile);
    logger.info("A message logged to the file");
  }
}

   
    
  








Related examples in the same category