Mega Code Archive

 
Categories / Java Tutorial / Log
 

Setting the Log Level of a Logger

import java.util.logging.Level; import java.util.logging.Logger; public class Main {   public static void main(String[] argv) throws Exception {     // Get a logger     Logger logger = Logger.getLogger("com.mycompany");     // Set the level to a particular level     logger.setLevel(Level.INFO);     // Set the level to that of its parent     logger.setLevel(null);     // Turn off all logging     logger.setLevel(Level.OFF);     // Turn on all logging     logger.setLevel(Level.ALL);   } }