Example usage for java.util.logging FileHandler FileHandler

List of usage examples for java.util.logging FileHandler FileHandler

Introduction

In this page you can find the example usage for java.util.logging FileHandler FileHandler.

Prototype

public FileHandler() throws IOException, SecurityException 

Source Link

Document

Construct a default FileHandler .

Usage

From source file:com.mycompany.cassandrajavaclient.XmlParser.java

public static void main(String[] args) {
    try {/* www . jav  a  2  s . co m*/
        Handler handler = new FileHandler();
        Logger.getLogger("Eric").addHandler(handler);
        try {
            String filename = "/home/eric/NetBeansProjects/nickel/echantillon/Arkea/Arkea Sepa fichiers entrants/SCTSE_20160304T054638.XML";
            XmlParser parser = new XmlParser();
            SCTHandler sctHandler = new SCTHandler();
            parser.connect(sctHandler);
            parser.read(filename);
        } catch (IOException ex) {
            Logger.getLogger(XmlParser.class.getName()).log(Level.SEVERE, null, ex);
        }
    } catch (IOException | SecurityException ex) {
        Logger.getLogger(XmlParser.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:shuffle.fwk.ShuffleController.java

/**
 * The main which starts the program./*from w w w. j ava 2  s.c o  m*/
 * 
 * @param args
 *           unused.
 */
public static void main(String... args) {
    String userHomeArg = null;
    String levelToSetArg = null;

    if (args != null && args.length > 0) {
        userHomeArg = args[0];
        if (args.length > 1) {
            levelToSetArg = args[1];
        }
    }

    if (userHomeArg == null) {
        userHomeArg = System.getProperty("user.home") + File.separator + "Shuffle-Move";
    }
    setUserHome(userHomeArg);
    try {
        FileHandler handler = new FileHandler();
        Logger toRoot = LOG;
        while (toRoot.getParent() != null) {
            toRoot = toRoot.getParent();
        }
        toRoot.addHandler(handler);
    } catch (SecurityException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    if (levelToSetArg != null) {
        try {
            Level levelToSet = Level.parse(args[1]);
            Logger.getLogger(SimulationTask.class.getName()).setLevel(levelToSet);
            SimulationTask.setLogFiner(levelToSet.intValue() <= Level.FINER.intValue());
            Logger.getLogger(ShuffleModel.class.getName()).setLevel(levelToSet);
        } catch (Exception e) {
            LOG.fine("Cannot set simulation logging to that level: " + StringUtils.join(args));
        }
    }

    ShuffleController ctrl = new ShuffleController();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            ctrl.getFrame().launch();
        }
    });
}