I wanted to store logs in file in the format: [date time]: Log msg . And also supress the date line which comes after every log message while using java.util.logging . The link (java.util.logging: how to suppress date line) says that I have to overwrite logging.properties file, but I'm not able to locate this file on my Mac . Also, if I create new logging.properties file in src/res folder, then how to link the same in my java code? The code I'm using to write logs in file(but in the same old format) is :
public static void main(String[] args) {
Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
FileHandler fh;
try {
// This block configure the logger with handler and formatter
fh = new FileHandler("C:/temp/test/MyLogFile.log");
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
// the following statement is used to log any messages
logger.info("My first log");
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
logger.info("Hi How r u?");
}