<dependency> <groupId>java.util.logging</groupId> <artifactId>java-util-logging</artifactId> <version>1.2.1</version> </dependency> import java.util.logging.Logger; public class MyClass { private static final Logger LOGGER = Logger.getLogger(MyClass.class.getName()); // ... } LOGGER.info("This is an informational log message."); properties handlers=java.util.logging.ConsoleHandler java.util.logging.ConsoleHandler.level=INFO java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter com.mycompany.level=INFO com.mycompany.handlers=java.util.logging.ConsoleHandler import java.io.FileInputStream; import java.io.IOException; import java.util.logging.LogManager; public class Main { public static void main(String[] args) { try { LogManager.getLogManager().readConfiguration(new FileInputStream("logging.properties")); } catch (IOException e) { e.printStackTrace(); } // ... } }


上一篇:
下一篇:
切换中文