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:com.google.cloud.pubsub.v1.TopicAdminSmokeTest.java

public static void main(String args[]) {
    Logger.getLogger("").setLevel(Level.WARNING);
    try {/*from   ww  w.ja  v  a  2  s . c  o  m*/
        Options options = new Options();
        options.addOption("h", "help", false, "show usage");
        options.addOption(Option.builder().longOpt("project_id").desc("Project id").hasArg()
                .argName("PROJECT-ID").required(true).build());
        CommandLine cl = (new DefaultParser()).parse(options, args);
        if (cl.hasOption("help")) {
            HelpFormatter formater = new HelpFormatter();
            formater.printHelp("TopicAdminSmokeTest", options);
        }
        executeNoCatch(cl.getOptionValue("project_id"));
        System.out.println("OK");
    } catch (Exception e) {
        System.err.println("Failed with exception:");
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:org.dineth.shooter.client.Example.java

public static void main(String[] args) {

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://localhost:8080/upload");
    filename = "router.jpg";

    FileBody bin = new FileBody(new File(filename));
    StringBody fileName = null;/* ww  w  . j  a v  a  2  s .  c  om*/
    try {
        fileName = new StringBody(filename);
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
    }

    MultipartEntity reqEntity = new MultipartEntity();
    reqEntity.addPart("file", bin);
    reqEntity.addPart("filename", fileName);
    httppost.setEntity(reqEntity);

    HttpResponse response = null;
    try {
        response = httpclient.execute(httppost);
    } catch (IOException ex) {
        Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
    }
    HttpEntity resEntity = response.getEntity();

}

From source file:com.dclab.preparation.ReadTest.java

public static void main(String[] args) {
    try {/*from   w ww  . j av  a  2  s .c  om*/
        ReadTest app;
        app = new ReadTest("/Users/richardthorne/Downloads/forward-flow");
    } catch (IOException ex) {
        Logger.getLogger(ReadTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.google.cloud.monitoring.v3.MetricServiceSmokeTest.java

public static void main(String args[]) {
    Logger.getLogger("").setLevel(Level.WARNING);
    try {//from  w  w w .  j a v a2 s.c  o  m
        Options options = new Options();
        options.addOption("h", "help", false, "show usage");
        options.addOption(Option.builder().longOpt("project_id").desc("Project id").hasArg()
                .argName("PROJECT-ID").required(true).build());
        CommandLine cl = (new DefaultParser()).parse(options, args);
        if (cl.hasOption("help")) {
            HelpFormatter formater = new HelpFormatter();
            formater.printHelp("MetricServiceSmokeTest", options);
        }
        executeNoCatch(cl.getOptionValue("project_id"));
        System.out.println("OK");
    } catch (Exception e) {
        System.err.println("Failed with exception:");
        e.printStackTrace(System.err);
        System.exit(1);
    }
}

From source file:com.linuxrouter.netcool.test.DbPoolTest.java

public static void main(String[] args) {
    String host = "192.168.0.201";
    String port = "4100";
    String dbName = "alerts";
    String url = "jdbc:sybase:Tds:" + host + ":" + port + "/" + dbName;
    Driver drv = new com.sybase.jdbc3.jdbc.SybDriver();
    try {/*from  ww  w.  j  av  a2s  .  c  o m*/
        DriverManager.registerDriver(drv);
    } catch (SQLException ex) {
        Logger.getLogger(DbPoolTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, "root", "omni12@#");
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
            null);
    ObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory);
    poolableConnectionFactory.setPool(connectionPool);
    PoolingDataSource<PoolableConnection> poolingDataSource = new PoolingDataSource<>(connectionPool);
    try {
        Connection con = poolingDataSource.getConnection();
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("select * from alerts.status");
        int x = 0;
        while (rs.next()) {
            //System.out.println(":::" + rs.getString(1));
            x++;
        }
        System.out.println("::::::" + x);
    } catch (SQLException ex) {
        Logger.getLogger(DbPoolTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:bariopendatalab.ImportData.java

/**
 * @param args the command line arguments
 *///from   ww w .  j a va2 s  . com
public static void main(String[] args) {
    int i = 0;
    try {
        MongoClient client = new MongoClient("localhost", 27017);
        DBAccess dbaccess = new DBAccess(client);
        dbaccess.dropDB();
        dbaccess.createDB();
        FileReader reader = new FileReader(new File(args[0]));
        Iterable<CSVRecord> records = CSVFormat.EXCEL.withHeader().withIgnoreEmptyLines().withDelimiter(',')
                .parse(reader);
        i = 2;
        for (CSVRecord record : records) {
            String type = record.get("Tipologia");
            if (type == null || type.length() == 0) {
                Logger.getLogger(ImportData.class.getName()).log(Level.WARNING, "No type in line {0}", i);
            }

            String description = record.get("Nome");
            if (description != null && description.length() == 0) {
                description = null;
            }

            String address = record.get("Indirizzo");
            if (address != null && address.length() == 0) {
                address = null;
            }

            String civ = record.get("Civ");
            if (civ != null && civ.length() == 0) {
                civ = null;
            }

            if (address != null && civ != null) {
                address += ", " + civ;
            }

            String note = record.get("Note");
            if (note != null && note.length() == 0) {
                note = null;
            }

            String longitudine = record.get("Longitudine");
            String latitudine = record.get("Latitudine");
            if (longitudine != null && latitudine != null) {
                if (longitudine.length() > 0 && latitudine.length() > 0) {
                    try {
                        dbaccess.insert(type, description, address, note, Utils
                                .get2DPoint(Double.parseDouble(latitudine), Double.parseDouble(longitudine)));
                    } catch (NumberFormatException nex) {
                        dbaccess.insert(type, description, address, note, null);
                    }
                } else {
                    dbaccess.insert(type, description, address, note, null);
                }
            } else {
                dbaccess.insert(type, description, address, note, null);
            }
            i++;
        }
        reader.close();
    } catch (Exception ex) {
        Logger.getLogger(ImportData.class.getName()).log(Level.SEVERE, "Error line " + i, ex);
    }
}

From source file:invoice.GetInvoice.java

/**
 * @param args the command line arguments
 *//*from w w  w.ja v  a 2  s .  com*/
public static void main(String[] args) {

    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMaximumFractionDigits(2);
    nf.setMinimumFractionDigits(2);
    nf.setRoundingMode(RoundingMode.HALF_UP);

    try {
        JSONObject arg_json = new JSONObject(args[0]);
    } catch (JSONException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    HashMap<String, Object> hm = new HashMap<>();
    hm.put("duplicate", "");
    hm.put("distributor", "//oshan" + "\n" + "//kapuhempala" + "\n\nArea: " + "//galle");
    hm.put("customer", "//owner" + "\n" + "//Agro" + "\n" + "//Agro add" + "\n" + "//0771894851");
    hm.put("invNo", "GSLTS" + String.format("%04d", Integer.parseInt("//100")));
    hm.put("invDate", "2014-01-10");
    hm.put("invCode", "300");

    double invoiceTotal = 500000;
    if (5 > 0) {//ShopDiscount
        double discountprice = (invoiceTotal * 99) / 100;//getShopDiscount()
        hm.put("invoiceDiscount", nf.format((invoiceTotal) * 99 / 100));//getRetail_discount()

    } else {
        hm.put("invoiceDiscount", "");
    }
    hm.put("gross_total", nf.format(invoiceTotal));
    hm.put("invoiceTotal", nf.format(((invoiceTotal) * (100 - 99) / 100)));//getRetail_discount()
    hm.put("salesPersonName", "rep");
    hm.put("salesPersonContactNo", "0772189584");

    JTable jTable1 = new JTable();
    jTable1.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {},
            new String[] { "ITEMCODE", "DESCRIPTION", "QTY", "FREEQTY", "PRICE", "AMOUNT" }));
    String reportSource = "./ireports/invoice.jrxml";
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    try {
        JasperReport jr = JasperCompileManager.compileReport(reportSource);
        JasperPrint jp = JasperFillManager.fillReport(jr, hm, new JRTableModelDataSource(dtm));
        JasperPrintManager.printReport(jp, false);
    } catch (JRException ex) {
        Logger.getLogger(GetInvoice.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println("1");
}

From source file:net.vnt.ussdapp.util.ContextTest.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/context.xml" });
    ContextProperties ctxProp = (ContextProperties) Context.getInstance().getBean("ContextProperties");
    TXTParser parser = (TXTParser) Context.getInstance().getBean("TXTParser");
    String mainmenu = ctxProp.getProperty("ussdapp.wrong");
    try {/*  w w w . j  a v  a 2s .com*/
        Vector<String> vs = parser.readFields(mainmenu);
        Enumeration<String> ens = vs.elements();
        StringBuilder sb = new StringBuilder();
        while (ens.hasMoreElements()) {
            sb.append(ens.nextElement()).append("\n");
        }
        System.out.println(sb.toString());
    } catch (IOException ex) {
        Logger.getLogger(ContextTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println(System.getProperty("os.arch"));
}

From source file:urbanchart.java

public static void main(String[] arg) {
    final DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Housing(35%)($1050)", new Double(35));
    data.setValue("Debt(15%)($450)", new Double(15));
    data.setValue("transportation(15%)($450)", new Double(15));
    data.setValue("Food(15%)($450)", new Double(25));
    data.setValue("Saving(10%)($300)", new Double(10));
    JFreeChart chart = ChartFactory.createPieChart(
            "Average Distribution of expenses on income assuming 3000$/month (Urban areas)", data, true, true,
            false);// w w  w  .  j  a  va2s.  com
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final File file1 = new File("E:\\java projects\\hackathon1\\web\\piecharturban.jpg");
    try {
        ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
    } catch (IOException ex) {
        Logger.getLogger(urbanchart.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.mycompany.airportdatabasebuilder.DatabaseBuilder.java

public static void main(String[] args) {
    try {/*from  w  w w. ja  v a2 s.  co  m*/
        Dao dao = new Dao();
        JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
        CSVReader reader = new CSVReader(new FileReader("airportdata2.csv"));
        String[] nextLine;
        int i = 0;
        while ((nextLine = reader.readNext()) != null) {
            if (nextLine[4] == null || nextLine[4].equals(""))
                System.out.println("empty code found");
            else {
                jdbcTemplate.update(
                        "INSERT INTO airportdata (airport_name, city, country, iata) VALUES(?, ?, ?, ?)",
                        nextLine[1], nextLine[2], nextLine[3], nextLine[4]);
            }
            i++;
        }

        // Airport(1)/ City(2)/ Country(3)/ Code(4)
        System.out.println(i + " rows were read");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(DatabaseBuilder.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(DatabaseBuilder.class.getName()).log(Level.SEVERE, null, ex);
    }
}