1 package net.sourceforge.javalogging; 2 3 import java.util.logging.*; 4 5 8 public class HelloWorld { 9 private static Logger theLogger = Logger.getLogger( HelloWorld.class.getName() ); 10 public static void main( String [] args ) { 11 HelloWorld hello = new HelloWorld( "Hello Adam!" ); 12 hello.sayHello(); 13 LogManager.getLogManager().reset(); 14 } 15 16 private String theMessage; 17 18 public HelloWorld( String 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 ("Test exception")); 27 } 28 } | Popular Tags |