import java.util.logging.Logger; public class MyClass { private static final Logger logger = Logger.getLogger(MyClass.class.getName()); public static void main(String[] args) { logger.info("Hello world!"); } }
import java.util.logging.Level; import java.util.logging.Logger; public class MyClass { private static final Logger logger = Logger.getLogger(MyClass.class.getName()); public static void main(String[] args) { logger.setLevel(Level.FINE); logger.fine("This is a debug message."); } }In this example, we set the logging level to FINE using the setLevel() method of the Logger class. The FINE level is used to log the message "This is a debug message.". Package library: java.util.logging