log to file 'log.txt' with simple format

This commit is contained in:
HeshamTB 2020-11-27 05:33:13 +03:00
parent 2d8456c975
commit 1fa3e4f5f1
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -1,8 +1,8 @@
import sun.rmi.runtime.Log;
import java.util.*;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class MakkahCity {
@ -28,7 +28,17 @@ public class MakkahCity {
public static void main(String[] args) {
log.setLevel(Level.FINE);
log.info("Starting Hajj-simulation");
try {
FileHandler fileHandler = new FileHandler("log.txt");
SimpleFormatter f = new SimpleFormatter();
fileHandler.setFormatter(f);
log.addHandler(fileHandler);
log.log(Level.FINE,"File Handler passed");
}
catch (Exception e){
System.err.println("Cant start log");
}
log.log(Level.FINE,"Starting Hajj-simulation");
//Gen Camp
campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>();
campPerDistrict[District.ALAZIZIYA.ordinal()] = new ArrayList<>();