First define and initialize it:
Logger Logger = Logger.getlogger ("log");
If you want to enter the logger information into the specified file, you will write a filehandler, as follows:
String LogPath = "C:/mylog";//This is the path to the log file you specified
Filehandler Filehandler = new Filehandler (LogPath);
At this point, the log file format is the default XML format, if you want to change it into a general text format, format, as follows:
Filehandler.setformatter (New Fimpleformatter ());//Create a new format class, let it specify
Also, the Logger class uses the default output handler will display all the information you want to the console, and if you don't want it to be displayed to the console, write the following sentence:
Logger.setuseparenthandler (false);//This is the handler that specifies that the parent class is not used,
Then, add Filehandler to the logger:
Logger.addhandler (Fiehandler):
Finally you can use logger to write the information you want, O (∩_∩) o ... Ha ha.