Path of log file [duplicate]

2019-09-15 19:26发布

问题:

This question already has an answer here:

  • Where does java.util.logging.Logger store their log 3 answers

I have created a logger using:

private final static Logger logger = Logger.getLogger(newClass.class.getName());

but where can see the generated log file in my system/workspace ?

回答1:

By Default, it will not write those messages into a log file.

You will have to specify a file Handler to which the log messages to write.

Handler handler = new FileHandler("logfile.log", size, rt_cnt);
Logger.getLogger("").addHandler(handler);

Based on the file name and location which you are providing in the FileHandler constructor, it will create the file and write the message