package br.senac.turma02;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Nose {
	/**
	 * @param args
	 */
	// Obtain a suitable logger.
	private static Logger logger = Logger.getLogger(Nose.class.getName());

	public static void main(String[] args) {
        // Ignorando a configuracao default do Java/TRE
        // Send logger output to our FileHandler.
		
	    // Request that every detail gets logged.
        logger.setLevel(Level.ALL);  // default do JDK eh INFO
        
        // Log a simple INFO message.
        logger.info("doing stuff");
        
        FileHandler fh=null;
		try {
			fh =  new FileHandler("mylog.txt");
		} catch (SecurityException e) {
			// Log the error
			logger.log(Level.SEVERE,"Security Exception error",e);
		} catch (IOException e) {
			// Log the error
			logger.log(Level.SEVERE,"IO Exception error",e);
		}		
        logger.addHandler(fh);            // JDK saida default na Console
         
		// Log a FINE tracing message
		logger.fine("doing stuff");
		try{
			Wombat.sneeze();
		} catch (Exception ex){
			// Log the error
			logger.log(Level.WARNING,"trouble sneezing",ex);
		}
		logger.fine("done");
	}

}

