2015-09-07 11:44:36 -06:00
|
|
|
|
// logging/LoggingLevelManipulation.java
|
2015-11-14 16:18:05 -08:00
|
|
|
|
// <20>2016 MindView LLC: see Copyright.txt
|
2015-06-15 17:47:35 -07:00
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
public class LoggingLevelManipulation {
|
|
|
|
|
private static Logger
|
2015-11-03 12:00:44 -08:00
|
|
|
|
lgr = Logger.getLogger("com"),
|
2015-06-15 17:47:35 -07:00
|
|
|
|
lgr2 = Logger.getLogger("com.mindviewinc"),
|
2015-11-11 20:20:04 -08:00
|
|
|
|
util= Logger.getLogger("onjava"),
|
2015-06-15 17:47:35 -07:00
|
|
|
|
test= Logger.getLogger("com.mindviewinc.test"),
|
|
|
|
|
rand = Logger.getLogger("random");
|
|
|
|
|
static void printLogMessages(Logger logger) {
|
|
|
|
|
logger.finest(logger.getName() + " Finest");
|
|
|
|
|
logger.finer(logger.getName() + " Finer");
|
|
|
|
|
logger.fine(logger.getName() + " Fine");
|
|
|
|
|
logger.config(logger.getName() + " Config");
|
|
|
|
|
logger.info(logger.getName() + " Info");
|
|
|
|
|
logger.warning(logger.getName()+" Warning");
|
|
|
|
|
logger.severe(logger.getName() + " Severe");
|
|
|
|
|
}
|
|
|
|
|
static void logMessages() {
|
|
|
|
|
printLogMessages(lgr);
|
|
|
|
|
printLogMessages(lgr2);
|
|
|
|
|
printLogMessages(util);
|
|
|
|
|
printLogMessages(test);
|
|
|
|
|
printLogMessages(rand);
|
|
|
|
|
}
|
|
|
|
|
static void printLevels() {
|
|
|
|
|
System.out.println(" -- printing levels -- "
|
|
|
|
|
+ lgr.getName()
|
|
|
|
|
+ " : " + lgr.getLevel()
|
|
|
|
|
+ " " + lgr2.getName()
|
|
|
|
|
+ " : " + lgr2.getLevel()
|
|
|
|
|
+ " " + util.getName()
|
|
|
|
|
+ " : " + util.getLevel()
|
|
|
|
|
+ " " + test.getName()
|
|
|
|
|
+ " : " + test.getLevel()
|
|
|
|
|
+ " " + rand.getName()
|
|
|
|
|
+ " : " + rand.getLevel());
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
printLevels();
|
|
|
|
|
lgr.setLevel(Level.SEVERE);
|
|
|
|
|
printLevels();
|
|
|
|
|
System.out.println("net level: SEVERE");
|
|
|
|
|
logMessages();
|
|
|
|
|
util.setLevel(Level.FINEST);
|
|
|
|
|
test.setLevel(Level.FINEST);
|
|
|
|
|
rand.setLevel(Level.FINEST);
|
|
|
|
|
printLevels();
|
|
|
|
|
System.out.println(
|
|
|
|
|
"individual loggers set to FINEST");
|
|
|
|
|
logMessages();
|
|
|
|
|
lgr.setLevel(Level.FINEST);
|
|
|
|
|
printLevels();
|
|
|
|
|
System.out.println("net level: FINEST");
|
|
|
|
|
logMessages();
|
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
|
-- printing levels -- net : null com.mindviewinc : null
|
2015-11-11 20:20:04 -08:00
|
|
|
|
onjava : null com.mindviewinc.test : null
|
2015-06-15 17:47:35 -07:00
|
|
|
|
random : null
|
2015-09-07 11:44:36 -06:00
|
|
|
|
-- printing levels -- net : SEVERE com.mindviewinc : null
|
2015-11-11 20:20:04 -08:00
|
|
|
|
onjava : null com.mindviewinc.test : null
|
2015-06-15 17:47:35 -07:00
|
|
|
|
random : null
|
|
|
|
|
net level: SEVERE
|
2015-09-07 11:44:36 -06:00
|
|
|
|
-- printing levels -- net : SEVERE com.mindviewinc : null
|
2015-11-11 20:20:04 -08:00
|
|
|
|
onjava : FINEST com.mindviewinc.test : FINEST
|
2015-06-15 17:47:35 -07:00
|
|
|
|
random : FINEST
|
|
|
|
|
individual loggers set to FINEST
|
2015-09-07 11:44:36 -06:00
|
|
|
|
-- printing levels -- net : FINEST com.mindviewinc : null
|
2015-11-11 20:20:04 -08:00
|
|
|
|
onjava : FINEST com.mindviewinc.test : FINEST
|
2015-06-15 17:47:35 -07:00
|
|
|
|
random : FINEST
|
|
|
|
|
net level: FINEST
|
|
|
|
|
___[ Error Output ]___
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: net Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
INFO: onjava Info
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
WARNING: onjava Warning
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
SEVERE: onjava Severe
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc.test Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc.test Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc.test Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: random Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: random Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: random Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: net Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
INFO: onjava Info
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
WARNING: onjava Warning
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
SEVERE: onjava Severe
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc.test Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc.test Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc.test Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: random Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: random Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: random Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: net Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: net Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: net Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
INFO: onjava Info
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
WARNING: onjava Warning
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
2015-11-11 20:20:04 -08:00
|
|
|
|
SEVERE: onjava Severe
|
2015-06-15 17:47:35 -07:00
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: com.mindviewinc.test Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: com.mindviewinc.test Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: com.mindviewinc.test Severe
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
INFO: random Info
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
WARNING: random Warning
|
|
|
|
|
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
|
|
|
|
|
printLogMessages
|
|
|
|
|
SEVERE: random Severe
|
2015-09-07 11:44:36 -06:00
|
|
|
|
*/
|