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:net.jmhertlein.alphonseirc.MSTDeskEngRunner.java

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    loadConfig();/*from   w  ww .  j a va  2s .c om*/

    AlphonseBot bot = new AlphonseBot(nick, pass, server, channels, maxXKCD, noVoiceNicks, masters,
            dadLeaveTimes);
    bot.setMessageDelay(500);
    try {
        bot.startConnection();
    } catch (IOException | IrcException ex) {
        Logger.getLogger(MSTDeskEngRunner.class.getName()).log(Level.SEVERE, null, ex);
    }

    boolean quit = false;
    while (!quit) {
        String curLine = scan.nextLine();

        switch (curLine) {
        case "exit":
            System.out.println("Quitting.");
            bot.onPreQuit();
            bot.disconnect();
            bot.dispose();
            writeConfig();
            quit = true;
            System.out.println("Quit'd.");
            break;
        case "msg":
            Scanner lineScan = new Scanner(scan.nextLine());
            try {
                bot.sendMessage(lineScan.next(), lineScan.nextLine());
            } catch (Exception e) {
                System.err.println(e.getClass().toString());
                System.err.println("Not enough args");
            }
            break;
        default:
            System.out.println("Invalid command.");
        }
    }
}

From source file:Interface.Teste.java

public static void main(String[] args) {
    try {/*from   w w w  .ja  v a 2s  . c o m*/
        //Runtime.getRuntime().exec("cmd /c start Ajuda.pdf");
        Runtime.getRuntime().exec(
                "cmd /c start C://Users//Junior//Documents//NetBeansProjects//SnackBar1//src//Interface//Ajuda.pdf");
    } catch (IOException ex) {
        Logger.getLogger(Teste.class.getName()).log(Level.SEVERE, null, ex);
    }
    Teste t = new Teste();
    t.setSize(600, 600);
    t.setVisible(true);
    t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:checkdb.CheckDb.java

/**
 * @param args the command line arguments
 *//*from w ww  .j a  v a  2 s .  co m*/
public static void main(String[] args) {
    try {
        CheckDb me = new CheckDb();
        me.doAll(args);
    } catch (WebUtilException | SQLException | ClassNotFoundException | ViewConfigException ex) {
        Logger.getLogger(CheckDb.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ebay.Ebay.java

/**
 * @param args the command line arguments
 *//*  w w  w  .  j  av  a  2s .c  o  m*/
public static void main(String[] args) {
    HttpClient client = null;
    HttpResponse response = null;
    BufferedReader rd = null;
    Document doc = null;
    String xml = "";
    EbayDAO<Producto> db = new EbayDAO<>(Producto.class);
    String busqueda;

    while (true) {
        busqueda = JOptionPane.showInputDialog(null, "ingresa una busqueda");
        if (busqueda != null) {
            busqueda = busqueda.replaceAll(" ", "%20");
            try {
                client = new DefaultHttpClient();
                /*
                 peticion GET
                 */
                HttpGet request = new HttpGet("http://open.api.ebay.com/shopping?" + "callname=FindPopularItems"
                        + "&appid=student11-6428-4bd4-ac0d-6ed9d84e345" + "&version=517&QueryKeywords="
                        + busqueda + "&siteid=0" + "&responseencoding=XML");
                /*
                 se ejecuta la peticion GET
                 */
                response = client.execute(request);
                rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                /*
                 comienza la lectura de la respuesta a la peticion GET
                 */
                String line;
                while ((line = rd.readLine()) != null) {
                    xml += line + "\n";
                }
            } catch (IOException ex) {
                Logger.getLogger(Ebay.class.getName()).log(Level.SEVERE, null, ex);
            }

            /*
             creamos nuestro documentBulder(documento constructor) y obtenemos 
             nuestro objeto documento apartir de documentBuilder
             */
            try {
                DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                doc = documentBuilder.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8"))));
            } catch (ParserConfigurationException | SAXException | IOException ex) {
                Logger.getLogger(Ebay.class.getName()).log(Level.SEVERE, null, ex);
            }

            Element raiz = doc.getDocumentElement();
            if (raiz == null) {
                System.exit(0);
            }
            if (raiz.getElementsByTagName("Ack").item(0).getTextContent().equals("Success")) {
                NodeList array = raiz.getElementsByTagName("ItemArray").item(0).getChildNodes();
                for (int i = 0; i < array.getLength(); ++i) {
                    Node n = array.item(i);

                    if (n.getNodeType() != Node.TEXT_NODE) {
                        Producto p = new Producto();
                        if (((Element) n).getElementsByTagName("ItemID").item(0) != null)
                            p.setId(new Long(
                                    ((Element) n).getElementsByTagName("ItemID").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("EndTime").item(0) != null)
                            p.setEndtime(
                                    ((Element) n).getElementsByTagName("EndTime").item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("ViewItemURLForNaturalSearch").item(0) != null)
                            p.setViewurl(((Element) n).getElementsByTagName("ViewItemURLForNaturalSearch")
                                    .item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("ListingType").item(0) != null)
                            p.setListingtype(
                                    ((Element) n).getElementsByTagName("ListingType").item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("GalleryURL").item(0) != null)
                            p.setGalleryurl(
                                    ((Element) n).getElementsByTagName("GalleryURL").item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("PrimaryCategoryID").item(0) != null)
                            p.setPrimarycategoryid(new Integer(((Element) n)
                                    .getElementsByTagName("PrimaryCategoryID").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("PrimaryCategoryName").item(0) != null)
                            p.setPrimarycategoryname(((Element) n).getElementsByTagName("PrimaryCategoryName")
                                    .item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("BidCount").item(0) != null)
                            p.setBidcount(new Integer(
                                    ((Element) n).getElementsByTagName("BidCount").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("ConvertedCurrentPrice").item(0) != null)
                            p.setConvertedcurrentprice(new Double(((Element) n)
                                    .getElementsByTagName("ConvertedCurrentPrice").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("ListingStatus").item(0) != null)
                            p.setListingstatus(((Element) n).getElementsByTagName("ListingStatus").item(0)
                                    .getTextContent());
                        if (((Element) n).getElementsByTagName("TimeLeft").item(0) != null)
                            p.setTimeleft(
                                    ((Element) n).getElementsByTagName("TimeLeft").item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("Title").item(0) != null)
                            p.setTitle(((Element) n).getElementsByTagName("Title").item(0).getTextContent());
                        if (((Element) n).getElementsByTagName("ShippingServiceCost").item(0) != null)
                            p.setShippingservicecost(new Double(((Element) n)
                                    .getElementsByTagName("ShippingServiceCost").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("ShippingType").item(0) != null)
                            p.setShippingtype(((Element) n).getElementsByTagName("ShippingType").item(0)
                                    .getTextContent());
                        if (((Element) n).getElementsByTagName("WatchCount").item(0) != null)
                            p.setWatchcount(new Integer(
                                    ((Element) n).getElementsByTagName("WatchCount").item(0).getTextContent()));
                        if (((Element) n).getElementsByTagName("ListedShippingServiceCost").item(0) != null)
                            p.setListedshippingservicecost(
                                    new Double(((Element) n).getElementsByTagName("ListedShippingServiceCost")
                                            .item(0).getTextContent()));
                        try {
                            db.insert(p);
                        } catch (Exception e) {
                            db.update(p);
                        }
                    }
                }
            }
            Ventana.crear(xml);
        } else
            System.exit(0);

    }
}

From source file:MainProgram.MainProgram.java

public static void main(String[] args) throws InterruptedException, FileNotFoundException {
    MainFrame mainFrame = new MainFrame();
    errorLog = new PrintStream(file);
    try {//w  ww  . j  a va2s  . c  o m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        ex.printStackTrace(errorLog);
        Logger.getLogger(MainProgram.class.getName()).log(Level.SEVERE, null, ex);
    }
    SwingUtilities.updateComponentTreeUI(mainFrame);
    mainFrame.setVisible(true);
    mainFrame.setSize(445, 415);
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setResizable(false);

}

From source file:es.upm.dit.gsi.barmas.dataset.utils.DatasetSplitter.java

/**
 * @param args//from  w  w w .  j  a v  a2 s .c om
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    DatasetSplitter splitter = new DatasetSplitter();

    String originalDatasetPath = "src/main/resources/dataset/kr-vs-k.csv";
    String outputParentDir = "../experiments/output-data-splitter/chess";
    Logger logger = Logger.getLogger(DatasetSplitter.class.getSimpleName());

    // // Experiment 1
    // String outputDir = outputParentDir;
    // splitter.splitDataset(0.3, 4, originalDatasetPath, outputDir, true,
    // "CZ02", logger, 2);
    //
    // // Experiment 2
    // outputDir = outputParentDir;
    // splitter.splitDataset(0.3, 8, originalDatasetPath, outputDir, true,
    // "CZ02", logger, 2);
    //
    // // Experiment 3
    // outputDir = outputParentDir;
    // splitter.splitDataset(3, 2, 4, originalDatasetPath, outputDir,
    // "CZ02", logger);

    // Experiment 3
    String outputDir = outputParentDir;
    splitter.splitDataset(10, 2, 10, originalDatasetPath, outputDir, "chess", logger);

}

From source file:com.left8.evs.evs.EvS.java

/**
 * Main method that provides a simple console input interface for the user,
 * if she wishes to execute the tool as a .jar executable.
 * @param args A list of arguments.//w w  w  .  j a v  a 2  s.  c o  m
 * @throws org.apache.commons.cli.ParseException ParseExcetion
 */
public static void main(String[] args) throws ParseException {

    Config config = null;
    try {
        config = new Config();
    } catch (IOException ex) {
        Utilities.printMessageln("Configuration file 'config.properties' " + "not in classpath!");
        Logger.getLogger(EvS.class.getName()).log(Level.SEVERE, null, ex);
        System.exit(1);
    }

    if (args.length != 0) { //If the user supplied arguments
        Console console = new Console(args, config); //Read the console

        showMongoLogging = console.showMongoLogging();
        showInlineInfo = console.showInlineInfo();
        hasExtCommands = console.hasExternalCommands();
        choice = console.getChoiceValue();
    }

    if (!showMongoLogging) {
        //Stop reporting logging information
        Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
        mongoLogger.setLevel(Level.SEVERE);
    }

    System.out.println("\n----EvS----");

    if (!hasExtCommands) {
        System.out.println("Select one of the following options");
        System.out.println("1. Run Offline Peak Finding experiments.");
        System.out.println("2. Run EDCoW experiments.");
        System.out.println("3. Run each of the above methods without " + "the sentiment annotations.");
        System.out.println("Any other key to exit.");
        System.out.println("");
        System.out.print("Your choice: ");

        Scanner keyboard = new Scanner(System.in);
        choice = keyboard.nextInt();
    }

    switch (choice) {
    case 1: { //Offline Peak Finding
        int window = 10;
        double alpha = 0.85;
        int taph = 1;
        int pi = 5;
        Dataset ds = new Dataset(config);
        PeakFindingCorpus corpus = new PeakFindingCorpus(config, ds.getTweetList(), ds.getSWH());
        corpus.createCorpus(window);

        List<BinPair<String, Integer>> bins = BinsCreator.createBins(corpus, config, window);
        PeakFindingSentimentCorpus sCorpus = new PeakFindingSentimentCorpus(corpus);

        SentimentPeakFindingExperimenter exper = new SentimentPeakFindingExperimenter(sCorpus, bins, alpha,
                taph, pi, window, config);

        //Experiment with Taph
        List<String> lines = exper.experimentUsingTaph(1, 10, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingTaph(1, 10, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingTaph(1, 10, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        //Experiment with Alpha
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingAlpha(0.85, 0.99, 0.01, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        break;
    }
    case 2: { //EDCoW
        Dataset ds = new Dataset(config);
        SentimentEDCoWCorpus corpus = new SentimentEDCoWCorpus(config, ds.getTweetList(), ds.getSWH(), 10);

        corpus.getEDCoWCorpus().createCorpus();
        corpus.getEDCoWCorpus().setDocTermFreqIdList();
        int delta = 5, delta2 = 11, gamma = 6;
        double minTermSupport = 0.001, maxTermSupport = 0.01;

        SentimentEDCoWExperimenter exper = new SentimentEDCoWExperimenter(corpus, delta, delta2, gamma,
                minTermSupport, maxTermSupport, choice, choice, config);

        //Experiment with delta
        List<String> lines = exper.experimentUsingDelta(1, 20, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingDelta(1, 20, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingDelta(1, 20, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        //Experiment with gamma
        lines = exper.experimentUsingGamma(6, 10, 1, 0, showInlineInfo);
        exper.exportToFile("stanford.txt", lines);
        lines = exper.experimentUsingGamma(6, 10, 1, 1, showInlineInfo);
        exper.exportToFile("naive_bayes.txt", lines);
        lines = exper.experimentUsingGamma(6, 10, 1, 2, showInlineInfo);
        exper.exportToFile("bayesian_net.txt", lines);

        break;
    }
    case 3: {
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 0);
        break;
    }
    case 4: { //Directly run OPF
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 1);
        break;
    }
    case 5: { //Directly run EDCoW
        EDMethodPicker.selectEDMethod(config, showInlineInfo, 2);
        break;
    }
    default: {
        System.out.println("Exiting now...");
        System.exit(0);
    }
    }
}

From source file:net.ovres.tuxcourser.TuxCourser.java

public static void main(String[] argss) throws Exception {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("WARN|INFO|FINE").hasArg()
            .withDescription("Set the log level. Valid values include WARN, INFO, and FINE.")
            .withLongOpt("loglevel").create("l"));
    options.addOption("h", "help", false, "Displays this help and exits");
    options.addOption("v", "version", false, "Displays version information and exits");

    options.addOption(OptionBuilder.withArgName("TYPE").hasArg()
            .withDescription("Sets the output type. Valid values are tux11 and ppracer05").withLongOpt("output")
            .create());/*  w  w w  .  j a  va2  s  .  com*/

    CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, argss);
    } catch (ParseException exp) {
        System.err.println(exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar TuxCourser.jar [Options]", "Options", options, "");
        System.exit(-1);
    }

    if (line.hasOption("loglevel")) {
        String lvl = line.getOptionValue("loglevel");
        Level logLevel = Level.parse(lvl);
        Logger.getLogger("net.ovres.tuxcourser").setLevel(logLevel);
    }

    if (line.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar TuxCourser.jar [Options]", "Options", options, "");
        return;
    }
    if (line.hasOption("version")) {
        System.out.println("TuxCourser Version " + Settings.getVersion());
        return;
    }

    String[] remaining = line.getArgs();

    // Initialize all the different item and terrain types
    ModuleClassLoader.load();

    if (remaining.length == 0) { // Just show the gui.
        //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        new net.ovres.tuxcourser.gui.TuxCourserGui().setVisible(true);
    } else if (remaining.length == 3) {
        new TuxCourser().convertCourse(new File(remaining[0]), new File(remaining[1]), remaining[2],
                TYPE_TUXRACER11);
    } else {
        usage();
        System.exit(-1);
    }
}

From source file:eval.dataset.ParseWikiLog.java

public static void main(String[] ss) throws FileNotFoundException, ParserConfigurationException, IOException {
    FileInputStream fin = new FileInputStream("data/enwiki-20151201-pages-logging.xml.gz");
    GzipCompressorInputStream gzIn = new GzipCompressorInputStream(fin);
    InputStreamReader reader = new InputStreamReader(gzIn);
    BufferedReader br = new BufferedReader(reader);
    PrintWriter pw = new PrintWriter(new FileWriter("data/user_page.txt"));
    pw.println(/*from   w  w w .j a  v a  2  s.c o  m*/
            "#list of user names and pages that they have edited, deleted or created. These info are mined from logitems of enwiki-20150304-pages-logging.xml.gz");
    TreeMap<String, Set<String>> userPageList = new TreeMap();
    TreeSet<String> pageList = new TreeSet();
    int counterEntry = 0;
    String currentUser = null;
    String currentPage = null;
    try {
        for (String line = br.readLine(); line != null; line = br.readLine()) {

            if (line.trim().equals("</logitem>")) {
                counterEntry++;
                if (currentUser != null && currentPage != null) {
                    updateMap(userPageList, currentUser, currentPage);
                    pw.println(currentUser + "\t" + currentPage);
                    pageList.add(currentPage);
                }
                currentUser = null;
                currentPage = null;
            } else if (line.trim().startsWith("<username>")) {
                currentUser = line.trim().split(">")[1].split("<")[0].replace(" ", "_");

            } else if (line.trim().startsWith("<logtitle>")) {
                String content = line.trim().split(">")[1].split("<")[0];
                if (content.split(":").length == 1) {
                    currentPage = content.replace(" ", "_");
                }
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(ParseWikiLog.class.getName()).log(Level.SEVERE, null, ex);
    }
    pw.println("#analysed " + counterEntry + " entries of wikipesia log file");
    pw.println("#gathered a list of unique user of size " + userPageList.size());
    pw.println("#gathered a list of pages of size " + pageList.size());
    pw.close();
    gzIn.close();

    PrintWriter pwUser = new PrintWriter(new FileWriter("data/user_list_page_edited.txt"));
    pwUser.println(
            "#list of unique users and pages that they have edited, extracted from logitems of enwiki-20150304-pages-logging.xml.gz");
    for (String user : userPageList.keySet()) {
        pwUser.print(user);
        Set<String> getList = userPageList.get(user);
        for (String page : getList) {
            pwUser.print("\t" + page);
        }
        pwUser.println();
    }
    pwUser.close();

    PrintWriter pwPage = new PrintWriter(new FileWriter("data/all_pages.txt"));
    pwPage.println("#list of the unique pages that are extracted from enwiki-20150304-pages-logging.xml.gz");
    for (String page : pageList) {
        pwPage.println(page);
    }
    pwPage.close();
    System.out.println("#analysed " + counterEntry + " entries of wikipesia log file");
    System.out.println("#gathered a list of unique user of size " + userPageList.size());
    System.out.println("#gathered a list of pages of size " + pageList.size());
}

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

public static void main(String[] args) {
    try {/*from   ww  w . j a v  a 2s .  c  o 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);
    }
}