2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.examples
;
9 import java
.util
.logging
.*;
12 * Illustrate control and redirection of World Wind logging.
15 * @version $Id: LoggingControl.java 2472 2007-07-31 22:49:29Z tgaskins $
17 public class LoggingControl
extends ApplicationTemplate
19 // Use the standard World Wind application template
20 private static class AppFrame
extends ApplicationTemplate
.AppFrame
24 super(true, true, false); // status bar, layer panel, not statistics panel
28 public static void main(String
[] args
)
30 // Get the World Wind logger by name.
31 Logger logger
= Logger
.getLogger("gov.nasa.worldwind");
33 // Turn off logging to parent handlers of the World Wind handler.
34 logger
.setUseParentHandlers(false);
36 // Create a console handler (defined below) that we use to write log messages.
37 final ConsoleHandler handler
= new MyHandler();
39 // Enable all logging levels on both the logger and the handler.
40 logger
.setLevel(Level
.ALL
);
41 handler
.setLevel(Level
.ALL
);
43 // Add our handler to the logger
44 logger
.addHandler(handler
);
46 // Start the application.
47 ApplicationTemplate
.start("World Wind Logging Control", AppFrame
.class);
50 private static class MyHandler
extends ConsoleHandler
52 public void publish(LogRecord logRecord
)
54 // Just redirect the record to ConsoleHandler for printing.
55 System
.out
.printf("Hey, this came from Me!\n");
56 super.publish(logRecord
);