2015-05-05 11:20:13 -07:00
|
|
|
//: logging/ConfigureLogging.java
|
|
|
|
// {JVMArgs: -Djava.util.logging.config.file=log.prop}
|
|
|
|
import java.util.logging.*;
|
|
|
|
|
|
|
|
public class ConfigureLogging {
|
2015-05-18 23:05:20 -07:00
|
|
|
static Logger
|
|
|
|
lgr = Logger.getLogger("net"),
|
|
|
|
lgr2 = Logger.getLogger("net.mindview"),
|
|
|
|
util= Logger.getLogger("net.mindview.util"),
|
|
|
|
test= Logger.getLogger("net.mindview.test"),
|
|
|
|
rand = Logger.getLogger("random");
|
2015-05-05 11:20:13 -07:00
|
|
|
public ConfigureLogging() {
|
2015-05-18 23:05:20 -07:00
|
|
|
/*
|
|
|
|
Set Additional formatters, Filters and
|
|
|
|
Handlers for the loggers here. You cannot
|
|
|
|
specify the Handlers for loggers except
|
|
|
|
the root logger from the configuration
|
|
|
|
file.
|
|
|
|
*/
|
2015-05-05 11:20:13 -07:00
|
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
|
|
sendLogMessages(lgr);
|
|
|
|
sendLogMessages(lgr2);
|
|
|
|
sendLogMessages(util);
|
|
|
|
sendLogMessages(test);
|
|
|
|
sendLogMessages(rand);
|
|
|
|
}
|
2015-05-18 23:05:20 -07:00
|
|
|
private static void
|
|
|
|
sendLogMessages(Logger logger) {
|
2015-05-05 11:20:13 -07:00
|
|
|
System.out.println(" Logger Name : "
|
2015-05-18 23:05:20 -07:00
|
|
|
+ logger.getName() + " Level: "
|
|
|
|
+ logger.getLevel());
|
2015-05-05 11:20:13 -07:00
|
|
|
logger.finest("Finest");
|
|
|
|
logger.finer("Finer");
|
|
|
|
logger.fine("Fine");
|
|
|
|
logger.config("Config");
|
|
|
|
logger.info("Info");
|
|
|
|
logger.warning("Warning");
|
|
|
|
logger.severe("Severe");
|
|
|
|
}
|
2015-05-18 23:05:20 -07:00
|
|
|
} /* Output: (Sample)
|
|
|
|
Logger Name : net Level: SEVERE
|
|
|
|
Logger Name : net.mindview Level: FINEST
|
|
|
|
Logger Name : net.mindview.util Level: INFO
|
|
|
|
Logger Name : net.mindview.test Level: FINER
|
|
|
|
Logger Name : random Level: SEVERE
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
SEVERE: Severe
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
FINEST: Finest
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
FINER: Finer
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
FINE: Fine
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
CONFIG: Config
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
INFO: Info
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
WARNING: Warning
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
SEVERE: Severe
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
INFO: Info
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
WARNING: Warning
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
SEVERE: Severe
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
FINER: Finer
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
FINE: Fine
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
CONFIG: Config
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
INFO: Info
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
WARNING: Warning
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
SEVERE: Severe
|
|
|
|
May 14, 2015 4:43:34 PM ConfigureLogging sendLogMessages
|
|
|
|
SEVERE: Severe
|
|
|
|
*///:~
|