Use Logger with simple formatter and FileHandler
import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; public class Main { public static void main(String[] args) throws Exception { Logger logger = Logger.getLogger("MyLog"); FileHandler fh; fh = new FileHandler("c:\\MyLogFile.log", true); logger.addHandler(fh); logger.setLevel(Level.ALL); SimpleFormatter formatter = new SimpleFormatter(); fh.setFormatter(formatter); logger.log(Level.WARNING, "My first log"); } }