Package utils

Source Code of utils.Log

package utils;

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


public class Log {
  private static final Log INSTANCE = new Log();
  private Logger logger;
  private FileHandler fh;
  private Log()
  {
    LogManager lm = LogManager.getLogManager();
      fh = null;
    try {
      fh = new FileHandler("dealer.log");
    } catch (SecurityException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
     
    logger = Logger.getLogger("BridgeDealer");
      lm.addLogger(logger);
      logger.setLevel(Level.INFO);
      fh.setFormatter(new SimpleFormatter());

      logger.addHandler(fh);
  }
 
  public static void write(String line)
  {
    INSTANCE.logger.log(Level.INFO,line);
 
 
  public static void close()
  {
    INSTANCE.fh.close();
  }
}
TOP

Related Classes of utils.Log

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.