OnJava8-Examples/logging/MultipleHandlers.java

22 lines
630 B
Java
Raw Normal View History

2015-05-05 11:20:13 -07:00
//: logging/MultipleHandlers.java
import java.util.logging.*;
public class MultipleHandlers {
private static Logger logger =
Logger.getLogger("MultipleHandlers");
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("MultipleHandlers.xml");
logger.addHandler(logFile);
logger.addHandler(new ConsoleHandler());
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 MultipleHandlers main
WARNING: Output to multiple handlers
May 14, 2015 3:29:53 PM MultipleHandlers main
WARNING: Output to multiple handlers
*///:~