Simplest: Call info()
method of global logger:
Logger.getGlobal().info("Edit->Copy menu item selected");
This will print the following message:
January 10,2022 10:12:15 PM LoggingImageViewer myFunction
INFO: Edit-> Copy menu item selected.
We can suppress logging by executing the following code
Logger.getGlobal().setLevel(Level.OFF);
Can Create a Custom Logger.
private static final Logger myLogger = Logger.getLogger("in.ac.iitm.onlinedegree");
Seven Logging Levels.
SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST.
By default, first three levels are logged.
logger.setLevel(Level.FINE);
Turn on all levels: logger.setLevel(Level.ALL);
Turn off all logging: logger.setLevel(Level.OFF);
Can also change logging properties through a configuration file.