OnJava8-Examples/logging/MultipleHandlers2.java

21 lines
592 B
Java
Raw Normal View History

2015-05-05 11:20:13 -07:00
//: logging/MultipleHandlers2.java
import java.util.logging.*;
public class MultipleHandlers2 {
private static Logger logger =
Logger.getLogger("MultipleHandlers2");
2015-05-18 23:05:20 -07:00
public static void
main(String[] args) throws Exception {
2015-05-05 11:20:13 -07:00
FileHandler logFile =
new FileHandler("MultipleHandlers2.xml");
logger.addHandler(logFile);
logger.addHandler(new ConsoleHandler());
logger.setUseParentHandlers(false);
2015-05-18 23:05:20 -07:00
logger.warning(
"Output to multiple handlers");
2015-05-05 11:20:13 -07:00
}
2015-05-18 23:05:20 -07:00
} /* Output:
May 14, 2015 3:29:53 PM MultipleHandlers2 main
WARNING: Output to multiple handlers
*///:~