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:MyTest.ParseJson.java

public static void main(String args[]) {
    try {/*from   ww  w  . j  a  va2 s. com*/
        FileReader reader = new FileReader(
                new File("data/NGS___RNA-seq_differential_expression_analysis-v1.ga"));
        System.out.println(reader);
        JSONParser parser = new JSONParser();
        JSONObject jo = (JSONObject) parser.parse(reader);
        JSONObject jsteps = (JSONObject) jo.get("steps");

        System.out.println(jsteps.size());
        System.out.println("---------------------------------------------------");
        for (int i = 0; i < jsteps.size(); i++) {
            JSONObject jstep_detail = (JSONObject) jsteps.get(String.valueOf(i));
            getDetailInfo(jstep_detail);

        }

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

}

From source file:com.google.cloud.logging.v2.LoggingSmokeTest.java

public static void main(String args[]) {
    Logger.getLogger("").setLevel(Level.WARNING);
    try {// w w w  . j  ava2s  .com
        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("LoggingSmokeTest", 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.schemaspy.Main.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger(Main.class.getName());

    final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
            "org.schemaspy.service");
    applicationContext.register(SchemaAnalyzer.class);

    if (argv.length == 1 && "-gui".equals(argv[0])) { // warning: serious temp hack
        new MainFrame().setVisible(true);
        return;//from w w w  .j a va2s.c om
    }

    SchemaAnalyzer analyzer = applicationContext.getBean(SchemaAnalyzer.class);

    int rc = 1;

    try {
        rc = analyzer.analyze(new Config(argv)) == null ? 1 : 0;
    } catch (ConnectionFailure couldntConnect) {
        logger.log(Level.WARNING, "Connection Failure", couldntConnect);
        rc = 3;
    } catch (EmptySchemaException noData) {
        logger.log(Level.WARNING, "Empty schema", noData);
        rc = 2;
    } catch (InvalidConfigurationException badConfig) {
        logger.info("");
        if (badConfig.getParamName() != null)
            logger.log(Level.WARNING, "Bad parameter specified for " + badConfig.getParamName());
        logger.log(Level.WARNING, "Bad config " + badConfig.getMessage());
        if (badConfig.getCause() != null && !badConfig.getMessage().endsWith(badConfig.getMessage()))
            logger.log(Level.WARNING, " caused by " + badConfig.getCause().getMessage());

        logger.log(Level.FINE, "Command line parameters: " + Arrays.asList(argv));
        logger.log(Level.FINE, "Invalid configuration detected", badConfig);
    } catch (ProcessExecutionException badLaunch) {
        logger.log(Level.WARNING, badLaunch.getMessage(), badLaunch);
    } catch (Exception exc) {
        logger.log(Level.SEVERE, exc.getMessage(), exc);
    }

    System.exit(rc);
}

From source file:ruralchart.java

public static void main(String[] arg) {
    final DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Housing(35%)($350)", new Double(35));
    data.setValue("Debt(15%)($150)", new Double(15));
    data.setValue("transportation(15%)($150)", new Double(15));
    data.setValue("Food(15%)($250)", new Double(25));
    data.setValue("Saving(10%)($100)", new Double(10));
    JFreeChart chart = ChartFactory.createPieChart(
            "Average Distribution of expenses on income assuming 1000$/month (Rural areas)", data, true, true,
            false);/*from ww w  . j ava 2  s .com*/
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    final File file1 = new File("E:\\java projects\\hackathon1\\web\\piechartrural.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.epitech.oliver_f.astextexls.MainClass.java

public static void main(String[] args) {
    initalizeOption();//from  w  ww . j  a  v  a 2  s . c o  m
    CommandLineParser parser = new BasicParser();
    CommandLine cl = null;
    try {
        cl = parser.parse(options, args);
    } catch (ParseException ex) {
        Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (cl != null && cl.hasOption("help")) {
        HelpFormatter hf = new HelpFormatter();
        hf.printHelp("astexte script", options);
    }
    if (cl.hasOption("folder") && cl.hasOption("file")) {
        launchWriteAndRead(cl.getOptionValue("folder"), cl.getOptionValue("file"));
        System.out.println("OK");

    } else {
        HelpFormatter hf = new HelpFormatter();
        hf.printHelp("astexte script", options);
    }
    launch(args);
}

From source file:com.eddy.malupdater.MalUpdater.java

public static void main(String args[]) {
    try {//from   w w  w.j  a v a  2 s . com
        initMainLogger();
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException ex) {
        Logger.getLogger(MalUpdater.class.getName()).log(Level.SEVERE, null, ex);
    }

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            form = new MalUpdaterForm();

            if (StringUtils.isEmpty(MyProperties.getUsername()) || MyProperties.getPassword().length <= 0) {
                CredentialsPanel credentialsPanel = CredentialsPanel.getInstance();
                credentialsPanel.setVisible(true);
            }
        }
    });
}

From source file:gpxparser.GpxParser.java

/**
 * @param args the command line arguments
 *//*from  w  w w  .  j av a  2  s .  com*/
public static void main(String[] args) {
    File input = new File("/home/yonseca/4.gpx");
    Track track = new Track();
    try {
        Document doc = Jsoup.parse(input, "UTF-8");
        //System.out.println(doc.text());
        Elements trackData = doc.getElementsByTag("trk");
        Elements trackName = trackData.select("name");
        track.setName(trackName.text());
        Elements trkPt = trackData.select("trkseg").select("trkpt");
        for (Iterator<Element> iterator = trkPt.iterator(); iterator.hasNext();) {
            Element dataPoint = iterator.next();
            Double lat = NumberUtils.toDouble(dataPoint.attr("lat"));
            Double lon = NumberUtils.toDouble(dataPoint.attr("lon"));
            Double altitude = NumberUtils.toDouble(dataPoint.select("ele").text());
            track.addPoint(lat, lon, altitude);
        }
        System.out.println("");

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

From source file:com.google.cloud.errorreporting.v1beta1.ReportErrorsServiceSmokeTest.java

public static void main(String args[]) {
    Logger.getLogger("").setLevel(Level.WARNING);
    try {/* www  .  java  2s  .  co 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("ReportErrorsServiceSmokeTest", 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.sociesc.findasmartphonespark.Main.java

public static void main(String[] args) {
    String apiPrefix = "api/v1/";

    //setIpAddress("192.168.56.1");
    setPort(9010);//from  w  w w  . j  ava2s  . c o  m

    try {
        Logger.getLogger(Main.class.getName()).log(Level.INFO, "Criando banco de dados");
        DatabaseUtils.seedDatabase();
    } catch (SQLException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    Dao<User> userDao = new Dao(User.class);

    get(apiPrefix + "/hello/:name", (request, response) -> {
        ObjectMapper objectMapper = new ObjectMapper();

        /*ArrayList<AccessPoint> arrayAp = new ArrayList<AccessPoint>();
                
        for (int i = 0; i < 10; i++) {
        AccessPoint ap = new AccessPoint();
        ap.setBSSID("AP" + i);
        ap.setSSID("00:00:00:0" + i);
        ap.setRSSI(-50 + i);
        ap.setSala("Sala" + i);
                
        arrayAp.add(ap);
                
        //System.out.println("Nome: " + ap.getBSSID() + " - Mac: " + ap.getSSID() + " - Sinal: " + ap.getRSSI());
        }
                
        String retornoJson = rwJson.writeJson(arrayAp);*/

        //objectMapper.readValue(URLDecoder.decode(request.params(":name"), "UTF-8"), new TypeReference(String("lol")));
        ArrayList<AccessPoint> arrayAp = null;
        try {
            arrayAp = rwJson.readJson(URLDecoder.decode(request.params(":name"), "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return arrayAp.get(0).getBSSID();

        //return "Hello: " + request.params(":name");
        //return arrayAp[0].get;
    });

    post(apiPrefix + "/findUser/:data", (request, response) -> {
        String userId = request.params(":data");

        ArrayList<AccessPoint> aps = rwJson.readJson(userId.toString());

        /*JsonObject json = new JsonObject();
                
        try {
        json = JsonObject.readFrom(request.params(":data"));
        } catch (Exception ex) {
        System.out.println("erro no json:\n" + ex.getMessage());
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        json.add("error", ex.getMessage());
        response.status(500);
        }*/
        try {
            for (int i = 0; i < aps.size(); i++) {
                System.out.println("Nome: " + aps.get(i).getBSSID() + " - Mac: " + aps.get(i).getSSID()
                        + " - Sinal: " + aps.get(i).getRSSI() + " - Sala: " + aps.get(i).getSala());
            }
        } catch (Exception ex) {
            System.out.println("erro no json:\n" + ex.getMessage());
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            //json.add("error", ex.getMessage());
            response.status(500);
            return ex.getMessage();
        }

        return userId.toString();
    });

    /*post(apiPrefix + "/findUser/", (request, response) ->{
     JsonObject json = new JsonObject();
            
    // Informaes do roteador/AP
    String[] BSSID; // basic service set identifier - nome da conexo
    String[] SSID; // service set identifier - identificador nico da conexo
    int[]    RSSI; // received signal strength indicator - potencia do sinal (-87 a -32)
    String   sala;
            
    String jsonBody = request.body();
    JsonObject reqJson = JsonObject.readFrom(jsonBody);
    JsonObject wifiJson = reqJson.get("wifi").asObject();
            
    System.out.println("reqJson.size()" + reqJson.size() + "\nwifiJson.size()" + wifiJson.size());
            
    RSSI = new int[wifiJson.size()];
    BSSID = new String[wifiJson.size()];
    SSID = new String[wifiJson.size()];
            
    try{
        for (int i = 0; i < wifiJson.size(); i++) {
            // recebe informaes das conexes encontradas
            BSSID[i] = wifiJson.get("BSSID").asString();
            SSID[i] = wifiJson.get("SSID").asString();
            RSSI[i] = wifiJson.get("RSSI").asInt();
        }
            
        return json.toString();
    }catch(Exception ex){
        System.out.println("erro no json:\n" + ex.getMessage());
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        json.add("error", ex.getMessage());
        response.status(500);
    }
    return json.toString();
    });*/

    get(apiPrefix + "/users", (request, response) -> {
        JsonObject json = new JsonObject();

        request.params();

        try {
            List<User> users = userDao.findAll();
            JsonArray usersJson = new JsonArray();
            for (User u : users) {
                JsonObject uJson = new JsonObject();
                uJson.add("id", u.getId());
                uJson.add("name", u.getName());
                uJson.add("email", u.getEmail());
                usersJson.add(uJson);
            }
            json.add("users", usersJson);

        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            json.add("error", ex.getMessage());
            response.status(500);
        }

        return json.toString();
    });

    /*get(apiPrefix + "/users/:id", (request, response) -> {
    Long userId = Long.parseLong(request.params(":id"));
    JsonObject json = new JsonObject();
    try{
        User user = userDao.findById(userId);
        if(user == null){
            json.add("error", "user not found");
            response.status(404);
            return json.toString();
        }
                
        JsonObject userJson = new JsonObject();
        userJson.add("id", user.getId());
        userJson.add("name", user.getName());
        userJson.add("email", user.getEmail());
        json.add("user", userJson);
        return json.toString();
                
    }catch(Exception ex){
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        json.add("error", ex.getMessage());
        response.status(500);
    }
            
    return json.toString();
    });*/

    delete(apiPrefix + "/users/:id", (request, response) -> {
        Long userId = Long.parseLong(request.params(":id"));
        JsonObject json = new JsonObject();
        try {
            userDao.removeById(userId);
            json.add("message", "user removed");
            response.status(200);
            return json.toString();
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            json.add("error", ex.getMessage());
            response.status(500);
        }

        return json.toString();
    });

    put(apiPrefix + "/users/:id", (request, response) -> {
        Long userId = Long.parseLong(request.params(":id"));
        JsonObject json = new JsonObject();
        try {
            String jsonBody = request.body();
            JsonObject reqJson = JsonObject.readFrom(jsonBody);
            JsonObject userJson = reqJson.get("user").asObject();
            String name = userJson.get("name") != null ? userJson.get("name").asString() : null;
            String email = userJson.get("email") != null ? userJson.get("email").asString() : null;
            String password = userJson.get("password") != null ? userJson.get("password").asString() : null;

            User user = userDao.findById(userId);

            if (name != null)
                user.setName(name);

            if (email != null)
                user.setEmail(email);

            if (password != null) {
                String passwordDigest = DatabaseUtils.criptPass(password);
                user.setPasswordDigest(passwordDigest);
            }

            userDao.update(user);

            JsonObject resUserJson = new JsonObject();
            resUserJson.add("id", user.getId());
            resUserJson.add("name", user.getName());
            resUserJson.add("email", user.getEmail());

            json.add("user", resUserJson);
            return json.toString();

        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            json.add("error", ex.getMessage());
            response.status(500);
        }
        return json.toString();
    });

    post(apiPrefix + "/users", (request, response) -> {
        JsonObject json = new JsonObject();
        try {
            String jsonBody = request.body();
            JsonObject reqJson = JsonObject.readFrom(jsonBody);
            JsonObject userJson = reqJson.get("user").asObject();
            User user = new User();
            user.setName(userJson.get("name").asString());
            user.setEmail(userJson.get("email").asString());
            user.setPasswordDigest(DatabaseUtils.criptPass("tempPass"));
            userDao.create(user);

            JsonObject resUserJson = new JsonObject();
            resUserJson.add("id", user.getId());
            resUserJson.add("name", user.getName());
            resUserJson.add("email", user.getEmail());
            resUserJson.add("passwordDigest", user.getPasswordDigest());

            json.add("user", resUserJson);
            return json.toString();
        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            json.add("error", ex.getMessage());
            response.status(500);
        }
        return json.toString();
    });

}

From source file:gomokuserver.GomokuServer.java

/**
 * @param args the command line arguments
 * @throws java.lang.InterruptedException
 */// w ww  . j  a  v  a2s .  com
public static void main(String[] args) throws InterruptedException {
    if (args.length != 1) {
        System.out.println("Run with listen portno as argument");
        return;
    }

    int portno = Integer.parseInt(args[0]);
    ServerSocket sc;
    try {
        System.out.print("Creating socket bound to " + portno + " ... ");
        sc = new ServerSocket(portno);

        System.out.println("DONE");
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
        return;
    }
    FrontOffice fo = new FrontOffice();
    Lobby lb = new Lobby();
    fo.setReferalLobby(lb);
    fo.start();
    lb.start();
    while (!interrupted()) {
        try {
            Socket playersocket = sc.accept();
            playersocket.setKeepAlive(true);
            System.out.println("Received client from " + playersocket.getInetAddress());
            fo.handle(playersocket);
        } catch (IOException ex) {
            Logger.getLogger(GomokuServer.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
    fo.interrupt();
    lb.interrupt();
    fo.join();
    lb.join();
}