Example usage for java.util.logging Logger getLogger

List of usage examples for java.util.logging Logger getLogger

Introduction

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

Prototype




@CallerSensitive
public static Logger getLogger(String name) 

Source Link

Document

Find or create a logger for a named subsystem.

Usage

From source file:popo.defcon.MsgMeCDC.java

/**
 * @param args the command line arguments
 *///from ww w  .  j  a  va  2  s  .c om
public static void main(String[] args) {
    MsgMeCDC m = new MsgMeCDC();
    while (true) {
        m.Parse();
        try {
            System.out.println("\n Starting Sleep");
            Thread.sleep((long) 600000);
            System.out.println("\n SLEEP Finished");
        } catch (InterruptedException ex) {
            System.out.println("\n SLEPP FAILED \n");
            Logger.getLogger(MsgMeCDC.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:info.sugoiapps.xoclient.XOverClient.java

/**
 * @param args the command line arguments
 *///from ww w .  ja va2 s  .c om

public static void main(String[] args) {
    // System.getProperty("user.dir")); gets working directory in the form: C:\Users\Munyosz\etc...\
    final String SEPARATOR = " - ";
    XOverClient client = new XOverClient();
    String ladrs = getLocalAddress();
    if (client.validAddress(ladrs)) {
        MACHINE_IP = ladrs;

    } else {
        JOptionPane.showMessageDialog(null,
                "Your machine's internal IP couldn't be retreived, program will exit.");
        System.exit(0);
    }

    REMOTE_IP = null;
    if (!new File(CONFIG_FILENAME).exists()) {
        while (REMOTE_IP == null || REMOTE_IP.equalsIgnoreCase(""))
            REMOTE_IP = JOptionPane
                    .showInputDialog("Enter the internal IP of the machine you want to connect to.\n"
                            + "Must be in the format 192.168.xxx.xxx");
        String machinename = JOptionPane.showInputDialog("Now enter a name for the machine with internal IP "
                + "\"" + REMOTE_IP + "\"" + "\n"
                + "You will be able to select this machine from a list the next time you start the program.");
        new ListWriter(CONFIG_FILENAME).writeList(machinename + SEPARATOR + REMOTE_IP, APPEND);
    } else {
        MachineChooser mc = new MachineChooser(CONFIG_FILENAME, SEPARATOR, client);
        mc.setVisible(true);
        mc.setAddressInfo(MACHINE_IP);

        while (REMOTE_IP == null) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                JOptionPane.showMessageDialog(null, ex.getMessage());
                Logger.getLogger(XOverClient.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    new XOverClientGUI(REMOTE_IP, MACHINE_IP).setVisible(true);
    new FileServer().execute();
}

From source file:di.uniba.it.tee2.shell.TEEShell.java

/**
 * language maindir encoding/*from   w w  w.ja v a  2s  .c o  m*/
 *
 * @param args the command line arguments
 */
public static void main(String[] args) {
    try {
        CommandLine cmd = cmdParser.parse(options, args);
        if (cmd.hasOption("l") && cmd.hasOption("d")) {
            TEEShell shell = new TEEShell(cmd.getOptionValue("l"), cmd.getOptionValue("d"),
                    cmd.getOptionValue("e", DEFAULT_CHARSET));
            shell.promptLoop();
        } else {
            HelpFormatter helpFormatter = new HelpFormatter();
            helpFormatter.printHelp("Run TEE2 shell", options, true);
        }
    } catch (ParseException | IOException ex) {
        Logger.getLogger(TEEShell.class.getName()).log(Level.SEVERE, "General error", ex);
    }
}

From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineTool.java

/**
 * Main (starting) method of the command line application.
 *
 * @param argv Array of command line arguments that are expected to be
 * filesystem paths to input XML documents with MathML to be unified.
 * @throws ParserConfigurationException If a XML DOM builder cannot be
 * created with the configuration requested.
 *///from  ww  w  .j  ava 2 s .c  o  m
public static void main(String argv[]) throws ParserConfigurationException {

    final Options options = new Options();
    options.addOption("p", "operator-unification", false, "unify operator in addition to other types of nodes");
    options.addOption("h", "help", false, "print help");

    final CommandLineParser parser = new DefaultParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, argv);
    } catch (ParseException ex) {
        printHelp(options);
        System.exit(1);
    }

    if (line != null) {
        if (line.hasOption('h')) {
            printHelp(options);
            System.exit(0);
        }
        operatorUnification = line.hasOption('p');

        final List<String> arguments = Arrays.asList(line.getArgs());
        if (arguments.size() > 0) {

            Document outerDocument = DOMBuilder.getDocumentBuilder().newDocument();
            Node rootNode = outerDocument.createElementNS(UNIFIED_MATHML_NS,
                    UNIFIED_MATHML_NS_PREFIX + ":" + UNIFIED_MATHML_BATCH_OUTPUT_ROOT_ELEM);
            outerDocument.appendChild(rootNode);

            for (String filepath : arguments) {
                try {

                    Document doc = DOMBuilder.buildDocFromFilepath(filepath);
                    MathMLUnificator.unifyMathML(doc, operatorUnification);
                    if (arguments.size() == 1) {
                        xmlStdoutSerializer(doc);
                    } else {
                        Node itemNode = rootNode.getOwnerDocument().createElementNS(UNIFIED_MATHML_NS,
                                UNIFIED_MATHML_NS_PREFIX + ":" + UNIFIED_MATHML_BATCH_OUTPUT_ITEM_ELEM);
                        Attr filenameAttr = itemNode.getOwnerDocument().createAttributeNS(UNIFIED_MATHML_NS,
                                UNIFIED_MATHML_NS_PREFIX + ":"
                                        + UNIFIED_MATHML_BATCH_OUTPUT_ITEM_FILEPATH_ATTR);
                        filenameAttr.setTextContent(String.valueOf(filepath));
                        ((Element) itemNode).setAttributeNodeNS(filenameAttr);
                        itemNode.appendChild(
                                rootNode.getOwnerDocument().importNode(doc.getDocumentElement(), true));
                        rootNode.appendChild(itemNode);

                    }

                } catch (SAXException | IOException ex) {
                    Logger.getLogger(MathMLUnificatorCommandLineTool.class.getName()).log(Level.SEVERE,
                            "Failed processing of file: " + filepath, ex);
                }
            }

            if (rootNode.getChildNodes().getLength() > 0) {
                xmlStdoutSerializer(rootNode.getOwnerDocument());
            }

        } else {
            printHelp(options);
            System.exit(0);
        }
    }

}

From source file:gr.forth.ics.isl.preprocessfilter2.controller.Controller.java

public static void main(String[] args) throws XPathExpressionException, ParserConfigurationException,
        SAXException, IOException, PreprocessFilterException, TransformerException, ParseException {
    PropertyReader prop = new PropertyReader();

    //The following block of code is executed if there are arguments from the command line
    if (args.length > 0) {

        try {/* w  w  w.j a  v a2s  .  c  o  m*/
            Options options = new Options();
            CommandLineParser PARSER = new PosixParser();
            Option inputFile = new Option("inputFile", true, "input xml file");
            Option outputFile = new Option("outputFile", true, "output xml file");
            Option parentNode = new Option("parentNode", true, "output xml file");
            Option newValuesFile = new Option("newValuesFile", true, "new values xml file");
            Option newParentNode = new Option("newParentNode", true, "new parent node");
            Option newValueTag = new Option("newValueTag", true, "new value tag");
            Option oldValueTag = new Option("oldValueTag", true, "old value tag");
            Option sameValueTag = new Option("sameValueTag", true, "same value tag");
            Option createNewValues = new Option("createNewValues", true, "create new values option");
            options.addOption(inputFile).addOption(outputFile).addOption(parentNode).addOption(newValuesFile)
                    .addOption(newParentNode).addOption(newValueTag).addOption(oldValueTag)
                    .addOption(sameValueTag).addOption(createNewValues);
            CommandLine cli = PARSER.parse(options, args);
            String inputFileArg = cli.getOptionValue("inputFile");
            String outputFileArg = cli.getOptionValue("outputFile");
            String parentNodeArg = cli.getOptionValue("parentNode");
            String newValuesFileArg = cli.getOptionValue("newValuesFile");
            String newParentNodeArg = cli.getOptionValue("newParentNode");
            String newValueTagArg = cli.getOptionValue("newValueTag");
            String oldValueTagArg = cli.getOptionValue("oldValueTag");
            String sameValueTagArg = cli.getOptionValue("sameValueTag");
            String createNewValuesArg = cli.getOptionValue("createNewValues");
            PreprocessFilterUtilities process = new PreprocessFilterUtilities();
            if (createNewValuesArg.equals("yes")) {
                if (process.createNewValuesFile(inputFileArg, newValuesFileArg, parentNodeArg)) {
                    System.out.println("Succesfull PreProcessing!!!");
                }
            } else {
                if (process.createOutputFile(inputFileArg, outputFileArg, parentNodeArg, newParentNodeArg,
                        newValueTagArg, oldValueTagArg, sameValueTagArg, newValuesFileArg)) {
                    System.out.println("Succesfull PreProcessing!!!");
                }
            }
        } catch (PreprocessFilterException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
            throw new PreprocessFilterException("PreProcess Filter Exception:", ex);
        }

    } //If there are no command line arguments then the .config file is being used.
    else {

        try {
            String inputFilePathProp = prop.getProperty(inputFilePath);
            String outputFilePathProp = prop.getProperty(outputFilePath);
            String parentNodeProp = prop.getProperty(parentNode);

            String newValuesFilePathProp = prop.getProperty(newValuesFilePath);
            String newParentNodeProp = prop.getProperty(newParentNode);
            String newValueTagProp = prop.getProperty(newValueTag);
            String oldValueTagProp = prop.getProperty(oldValueTag);
            String sameValueTagProp = prop.getProperty(sameValueTag);
            String createNewValuesFileProp = prop.getProperty(createNewValuesFile);

            PreprocessFilterUtilities process = new PreprocessFilterUtilities();

            //The filter's code is executed with the .config file's resources as parameters
            if (createNewValuesFileProp.equals("yes")) {
                process.createNewValuesFile(inputFilePathProp, newValuesFilePathProp, parentNodeProp);
            } else {
                process.createOutputFile(inputFilePathProp, outputFilePathProp, parentNodeProp,
                        newParentNodeProp, newValueTagProp, oldValueTagProp, sameValueTagProp,
                        newValuesFilePathProp);
            }
        } catch (PreprocessFilterException ex) {
            Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
            throw new PreprocessFilterException("PreProcess Filter Exception:", ex);
        }
    }

}

From source file:TestReadCustData.java

public static void main(String[] args) {
    AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", "debug=1");
    List<Customer> lCust = new ArrayList<>();
    try {/* w w w.  j a  v  a 2  s.  c o m*/
        List<String> s = Files.readAllLines(Paths.get("customer.txt"), Charsets.ISO_8859_1);

        for (String s1 : s) {
            if (!s1.startsWith("GRUP")) {
                Customer c = new Customer();
                try {
                    c.setId(Long.parseLong(s1.split("~")[3]));
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setId(Long.parseLong(s1.split("~")[3]));
                }
                try {
                    c.setNama(s1.split("~")[4]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setNama("");
                }
                try {
                    c.setShipto(s1.split("~")[9]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setShipto("");
                }
                try {
                    c.setKota(s1.split("~")[12]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setKota("");
                }
                try {
                    c.setProvinsi(s1.split("~")[13]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setProvinsi("");
                }
                try {
                    c.setKodePos(s1.split("~")[14]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setKodePos("");
                }
                try {
                    c.setNamaArea(s1.split("~")[2]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setNamaArea("");
                }
                try {
                    c.setDKLK(s1.split("~")[15]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setDKLK("");
                }
                try {
                    c.setCreditLimit(Long.parseLong(s1.split("~")[16]));
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setCreditLimit(new Long(0));
                }
                try {
                    c.setNpwp(s1.split("~")[11]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setNpwp("");
                }
                try {
                    c.setNamaWajibPajak(s1.split("~")[10]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setNamaWajibPajak("");
                }
                try {
                    c.setCreationDate(s1.split("~")[6]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setCreationDate("");
                }
                try {
                    c.setLastUpdateBy(s1.split("~")[17]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setLastUpdateBy("");
                }
                try {
                    c.setLastUpdateDate(s1.split("~")[18]);
                } catch (ArrayIndexOutOfBoundsException arrex) {
                    c.setLastUpdateDate("");
                }

                lCust.add(c);
            }

        }

        for (Customer c : lCust) {

            Customer cc = Ebean.find(Customer.class, c.getId());
            if (cc != null) {
                cc = c;
                Ebean.update(cc);
            }

            System.out.print(c.getId());
            System.out.print(" | ");
            System.out.print(c.getNama());
            System.out.print(" | ");
            System.out.print(c.getShipto());
            System.out.print(" | ");
            System.out.print(c.getNpwp());
            System.out.print(" | ");
            System.out.print(c.getNamaWajibPajak());
            System.out.println();
        }

    } catch (IOException ex) {
        Logger.getLogger(TestReadCustData.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.flagleader.builder.FlagLeader.java

public static void main(String[] paramArrayOfString) {
    Shell localShell = new Shell(16777216);
    localShell.setLocation(new Point(300, 200));
    localShell.setLayout(new FillLayout());
    Composite localComposite = new Composite(localShell, 0);
    localComposite.setLayout(new FillLayout());
    Label localLabel = new Label(localComposite, 0);
    Image localImage = ImageDescriptor
            .createFromURL(localShell.getClass().getClassLoader().getResource("icons/start.jpg")).createImage();
    localLabel.setImage(localImage);// w ww  .j a va  2s .  c  o m
    localShell.setSize(400, 300);
    localShell.setText("Visual Rules Solution");
    localShell.open();
    Init.a();
    String str = null;
    if (BuilderConfig.getInstance().isLoadDefault())
        str = RuleRepository.DEFAULTEXT;
    if (paramArrayOfString.length > 0)
        str = "";
    for (int i = 0; i < paramArrayOfString.length; i++)
        str = str + paramArrayOfString[i] + " ";
    Logger localLogger = Logger.getLogger("ruleengine");
    Object localObject;
    try {
        new File(SystemUtils.USER_HOME + File.separator + ".visualrules" + File.separator + "logs").mkdirs();
        FileHandler localFileHandler = new FileHandler(SystemUtils.USER_HOME + File.separator + ".visualrules"
                + File.separator + "logs" + File.separator + "logfile%u.%g.txt", 0, 10);
        localFileHandler.setFormatter(new com.flagleader.server.c());
        localFileHandler.setLevel(Level.ALL);
        Logger.getLogger("flagleader").addHandler(localFileHandler);
        localLogger.addHandler(localFileHandler);
    } catch (Exception localException1) {
        if (!b) {
            localObject = new ConsoleHandler();
            ((ConsoleHandler) localObject).setFormatter(new com.flagleader.server.c());
            ((ConsoleHandler) localObject).setLevel(Level.ALL);
            Logger.getLogger("flagleader").addHandler((Handler) localObject);
            localLogger.addHandler((Handler) localObject);
        }
    }
    if (!BuilderManager.checkLicense()) {
        localImage.dispose();
        localShell.dispose();
        return;
    }
    Property.getInstance().setEngineImplement("com.flagleader.engine.impl.SingleRuleEngineFactory");
    FlagLeader localFlagLeader = new FlagLeader();
    Property.getInstance().setUpdateInternateTime(0L);
    localFlagLeader.setBlockOnOpen(true);
    localFlagLeader.builderManager = new BuilderManager(localFlagLeader);
    if ((com.flagleader.manager.d.c.a("needLogin", false)) || (BuilderConfig.getInstance().isFirstLogin()))
        try {
            localObject = localFlagLeader.builderManager.getUserServer();
            if ((localObject == null) || (((String) localObject).length() == 0)
                    || (localFlagLeader.builderManager.getUserType() == 0)
                    || (localFlagLeader.builderManager.getUserid() == 0)) {
                localImage.dispose();
                localShell.dispose();
                return;
            }
        } catch (Exception localException2) {
            MessageDialog.openError(null, "",
                    ResourceTools.getMessage("loginserver.error") + localException2.getLocalizedMessage());
            localImage.dispose();
            localShell.dispose();
            return;
        }
    if ((str != null) && (new File(str).exists()))
        localFlagLeader.builderManager.getRulesManager().a(new File(str));
    localFlagLeader.initWindow();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").delete();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").delete();
    if (BuilderConfig.getInstance().isAutosave())
        new com.flagleader.builder.d.c(localFlagLeader.builderManager).b();
    if (BuilderConfig.getInstance().isAutoCheckVersion())
        new a(localFlagLeader.builderManager).b();
    new e().b();
    localImage.dispose();
    localShell.dispose();
    localFlagLeader.open();
    BuilderManager localBuilderManager = localFlagLeader.builderManager;
    localFlagLeader.getShell().addShellListener(new d(localBuilderManager));
}

From source file:net.sf.mpaxs.spi.computeHost.StartUp.java

/**
 *
 * @param args/*from w ww  .j ava  2s . c  o  m*/
 */
public static void main(String args[]) {
    FileHandler handler;
    try {
        handler = new FileHandler("computeHost.log");
        Logger logger = Logger.getLogger(StartUp.class.getName());
        logger.addHandler(handler);
    } catch (IOException ex) {
        Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex);
    }

    Options options = new Options();
    Option[] optionArray = new Option[] { OptionBuilder.withArgName("configuration").hasArg().isRequired()
            .withDescription("URL to configuration file for compute host").create("c") };
    for (Option opt : optionArray) {
        options.addOption(opt);
    }
    if (args.length == 0) {
        HelpFormatter hf = new HelpFormatter();
        hf.printHelp(StartUp.class.getCanonicalName(), options, true);
        System.exit(1);
    }
    GnuParser gp = new GnuParser();
    try {
        CommandLine cl = gp.parse(options, args);
        try {
            URL configURL = new URL(cl.getOptionValue("c"));
            PropertiesConfiguration cfg = new PropertiesConfiguration(configURL);
            StartUp su = new StartUp(cfg);
        } catch (ConfigurationException ex) {
            Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (ParseException ex) {
        Logger.getLogger(StartUp.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:cross.io.PropertyFileGenerator.java

/**
 *
 * @param args/*from w  w w .  j a v  a  2 s. co  m*/
 */
public static void main(String[] args) {
    Options options = new Options();
    options.addOption("f", true, "base directory for output of files");
    Option provOptions = new Option("p", true,
            "Comma separated list of provider classes to create Properties for");
    provOptions.setRequired(true);
    provOptions.setValueSeparator(',');
    options.addOption(provOptions);
    CommandLineParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    try {
        File basedir = null;
        List<String> providers = Collections.emptyList();
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("f")) {
            basedir = new File(cmd.getOptionValue("f"));
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        if (cmd.hasOption("p")) {
            String[] str = cmd.getOptionValues("p");
            providers = Arrays.asList(str);
        } else {
            hf.printHelp("java -cp maltcms.jar " + PropertyFileGenerator.class, options);
        }
        for (String provider : providers) {
            createProperties(provider, basedir);
        }
    } catch (ParseException ex) {
        Logger.getLogger(PropertyFileGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:eu.edisonproject.classification.main.BatchMain.java

public static void main(String[] args) throws Exception {
    try {/*from w  w w  . j  a v a  2 s . co  m*/
        //            args = new String[1];
        //            args[0] = "..";
        //            TestDataFlow.execute(args);
        //            System.exit(0);
        //            TestTFIDF.execute(args);

        Options options = new Options();

        Option operation = new Option("op", "operation", true, "type of operation to perform. "
                + "To convert txt to avro 'a'.\n" + "For running clasification on avro documents 'c'");
        operation.setRequired(true);
        options.addOption(operation);

        Option input = new Option("i", "input", true, "input path");
        input.setRequired(false);
        options.addOption(input);

        Option output = new Option("o", "output", true, "output file");
        output.setRequired(false);
        options.addOption(output);

        Option competencesVector = new Option("c", "competences-vector", true, "competences vectors");
        competencesVector.setRequired(false);
        options.addOption(competencesVector);

        Option v1 = new Option("v1", "vector1", true, "");
        v1.setRequired(false);
        options.addOption(v1);

        Option v2 = new Option("v2", "vector2", true, "");
        v2.setRequired(false);
        options.addOption(v2);

        Option popertiesFile = new Option("p", "properties", true, "path for a properties file");
        popertiesFile.setRequired(false);
        options.addOption(popertiesFile);

        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);
        String propPath = cmd.getOptionValue("properties");
        MyProperties prop;
        if (propPath == null) {
            prop = ConfigHelper
                    .getProperties(".." + File.separator + "etc" + File.separator + "configure.properties");
        } else {
            prop = ConfigHelper.getProperties(propPath);
        }

        switch (cmd.getOptionValue("operation")) {
        case "a":
            text2Avro(cmd.getOptionValue("input"), cmd.getOptionValue("output"), prop);
            break;
        case "c":
            calculateTFIDF(cmd.getOptionValue("input"), cmd.getOptionValue("output"),
                    cmd.getOptionValue("competences-vector"), prop);
            break;
        case "p":
            //                    -op p -v2 $HOME/Downloads/msc.csv -v1 $HOME/Downloads/job.csv -p $HOME/workspace/E-CO-2/etc/classification.properties
            profile(cmd.getOptionValue("v1"), cmd.getOptionValue("v2"), cmd.getOptionValue("output"));
            break;
        }

    } catch (IllegalArgumentException | ParseException | IOException ex) {
        Logger.getLogger(BatchMain.class.getName()).log(Level.SEVERE, null, ex);
    }

}