Logger logger = Logger.getLogger("myLogger"); String name = logger.getName(); System.out.println(name); // output: "myLogger"
Logger logger = Logger.getAnonymousLogger(); String name = logger.getName(); System.out.println(name); // output: "anonymous"This example creates an anonymous logger using the Logger.getAnonymousLogger() method. The getName() method is then used to get the name of the logger which will be "anonymous". The java.util.logging.Logger is a part of the standard Java library and does not require any external packages or libraries.