Download LoggingDemo.java source file
// Demo of Java SE logging API
// Written 10/2007 by Wayne Pollock, Tampa Florida USA.
import java.util.logging.*;
import static java.util.logging.Level.*;
public class LoggingDemo
{
// Create a default console logger:
private static Logger logger = Logger.getLogger("LoggingDemo");
private static final String className = "LoggingDemo";
public static void main ( String [] args )
{
// Let logger guess the class and method:
logger.info( "Starting Application\n" );
doSomethingInteresting();
logger.info( "Ending Application\n" );
}
static void doSomethingInteresting ()
{
// Tell logger the the class and method:
logger.logp( INFO, className, "doSomethingInteresting",
"Attempting to take over the world\n" );
logger.logp( SEVERE, className, "doSomethingInteresting",
"Failed to take over the world!\n" );
}
}