Data Types and Exceptions in Java
Jim White
Java Developer
System.out.println()
to leave messages in the consolejava.util.logging
Logger
objectgetLogger(String)
to get a Logger objectString
names the loggerimport java.util.logging.*;
class HelloWorld {
public static Logger logger =
Logger.getLogger("HelloWorld");
}
public static void main (String[] args) {
logger.log(Level.INFO,
"This is informational");
logger.log(Level.SEVERE,
"This is a critical message");
}
Nov 26, 2024 12:59:29 PM HelloWorld main
INFO: This is informational
Nov 26, 2024 12:59:29 PM HelloWorld main
SEVERE: This is a critical message
Level | Order |
---|---|
SEVERE | highest importance |
WARNING | |
INFO | |
CONFIG | |
FINE | |
FINER | |
FINEST | lowest importance |
Data Types and Exceptions in Java