Copyright: hard code word, when you reprint remember to tell me https://blog.csdn.net/dxyinme/article/details/90216764
This is a built-in log java class
Using logs do not forget to import these two
import java.util.logging.*;
import static java.util.logging.Logger.getLogger;
1. Create a class corresponding to the current logger
static final Logger logger = getLogger(CommandInfoReader.class.getName());
2. If you want to save the file logger
because of problems reading and writing files, this handler could lead to open conflict duplicate files, but it does not matter ...
as long as that information at the end of all extra and can be in a file inside.
FileHandler filehandler = new FileHandler(fileName, true);
logger.addHandler(filehandler);//绑定文件
logger.removeHandler(filehandler);//解除绑定
3.logger several levels
(Anyway, I used these three, a warning / information / in good condition)
logger.warning(xxx);
logger.info(xxx);
logger.fine(xxx);