I'm trying to create a log file in java, but the problem is, Whenever any thing is writing inside the log file(.txt file) it is showing the date and time . I want this to be removed every time when I'm writing anything inside the logfile.
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class Logfile {
public static void main(String[] args) {
// TODO Auto-generated method stub
Logger logger = Logger.getLogger("MyLog");
FileHandler fh;
try {
fh = new FileHandler("D:\\New/MyLogFile.log");
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
logger.info("My first log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
logger.info("Hi How r u?");
}
}
Aug 21, 2019 4:33:51 PM Log.Logfile main INFO: My first log Aug 21, 2019 4:33:51 PM Log.Logfile main INFO: Hi How r u?