import java.util.logging.Logger; public class LoggingExample { public static void main(String[] args) { Logger logger = Logger.getAnonymousLogger(); logger.info("Hello, world!"); } }
import java.util.logging.Level; import java.util.logging.Logger; public class LoggingExample { public static void main(String[] args) { Logger logger = Logger.getAnonymousLogger(); logger.setLevel(Level.WARNING); logger.warning("Danger, Will Robinson!"); } }This example creates a new anonymous logger and sets its logging level to WARNING. It then logs a warning message. Package Library: The java.util.logging package is part of the Java Platform Standard Edition (Java SE) library.