Because you don't want to import log4j jars, the project is just testing something, so choosing the logging that comes with the JDK is a good choice for small projects or testing something for yourself.
In log4j, the output of the log is controlled by log4j.properties this configuration file, and the Java logging is done with similar functionality through logging.properties files.
The Logging.properties file is located in the jre/lib/directory of the JDK installation path, directly on the configuration file:
handlers= java.util.logging.ConsoleHandler.level ==%h/java%= 50000= 1 = == Java.util.logging.SimpleFormatter
You want to enter both the console and the revenue in the file, as set below.
handlers= Java.util.logging.FileHandler, Java.util.logging.ConsoleHandler
The format requirements for the log file are set to the following line:
Java.util.logging.FileHandler.pattern =%h/java%u.log
Specify how to define, and you can view the Java Logging Format API to set it up.
The above settings allow you to enter the log into the specified file requirements. But sometimes just want some kind of file output to make, so debugging more clear, in order to achieve the requirements of a few more settings.
Com.jason.logger.LoggerDemo.level == Java.util.logging.FileHandler
"Com.spt.logger.LoggerDemo" is the name of "Logger", which matches the logger specified in the code.
C program in use, the code is as follows:
Private Static Logger log = Logger.getlogger (Loggerdemo. Class. GetName ());
By the way, I also forgot the logging several levels to do the introduction:
SEVERE (highest level) WARNING INFO CONFIG FINE finer FINEST (lowest level)
Simple use of these is enough, and then the use of complex, personal feeling will be on the log4j.
How to use Java loggingapi