KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > javalogging > HelloWorld


1 package net.sourceforge.javalogging;
2
3 import java.util.logging.*;
4
5 /**
6 * A simple Java Hello World program, in the tradition of Kernighan and Richie.
7 */

8 public class HelloWorld {
9     private static Logger theLogger = Logger.getLogger( HelloWorld.class.getName() );
10     public static void main( String JavaDoc[] args ) {
11         HelloWorld hello = new HelloWorld( "Hello Adam!" );
12         hello.sayHello();
13         LogManager.getLogManager().reset();
14     }
15
16     private String JavaDoc theMessage;
17
18     public HelloWorld( String JavaDoc message ) {
19         theMessage = message;
20     }
21
22     public void sayHello() {
23         theLogger.info( theMessage );
24         theLogger.severe( "Does this work" );
25         theLogger.info( "Anything" );
26         theLogger.log(Level.SEVERE, "Threw an exception", new Exception JavaDoc("Test exception"));
27     }
28 }
Popular Tags