Flush File Handler and Logger
import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; public class Main { public static void main(String[] args) throws Exception { FileHandler handler = null; Logger logger = Logger.getLogger("logging"); handler = new FileHandler("pattern", 1000, 2); logger.addHandler(handler); LogRecord record = new LogRecord(Level.INFO, "Logged in a file..."); logger.log(record); handler.flush(); handler.close(); } }