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:br.com.itfox.utils.SendHtmlFormatedEmail.java

public static void main(String[] args) {
    try {//from  w  w w. ja v a 2s  .c om
        //new SendHtmlFormatedEmail().sendingHtml();
        String assunto = "";
        Mensagem msg = new Mensagem();
        // localizando a mensagem
        //msg = new BusinessDelegate().getMensagem(new BigDecimal(61));
        //assunto = msg.getAssunto();
        new SendHtmlFormatedEmail().sendingHtml(" ", " 87680087", "Pablo Pereira", "belchiorpalma@gmail.com");
    } catch (Exception ex) {
        Logger.getLogger(SendHtmlFormatedEmail.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.curso.ejemplotareaplanificada.Principal.java

/**
 * @param args the command line arguments
 *///from   ww w .j  av a 2  s.  c  om
public static void main(String[] args) {
    //solo estamos usando anotaciones
    //en esta clase no hay nada de los metodos planificados porque esos ya los llama spring solito
    //esta clase es para pegarnos con los servicios asincronos
    ApplicationContext ctx = new AnnotationConfigApplicationContext(Configuracion.class);
    System.out.println("Contexto cargado");
    ServicioAsincrono sa = ctx.getBean(ServicioAsincrono.class);
    System.out.println("Hilo principal " + Thread.currentThread());

    //Este metodo devuelve void asi que el hilo arranca un nuevo hilo pero continua sin esperar ni ahora ni a un futuro
    sa.metodoUno();

    //Este metodo devuelve un futuro, y cuando llamemos a get espera 5 segundos a ver si termina el nuevo hilo
    //Si sobre pasa esos 5 segundos lanza una excepcion
    Future<Double> numero = sa.factorial(100);
    try {
        System.out.println("El factorial es desde un Future:" + numero.get(5L, TimeUnit.SECONDS));
    } catch (InterruptedException | ExecutionException | TimeoutException ex) {
        Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }

    //Este metodo devuelve un escuchable
    ListenableFuture<Double> valor = sa.factorialLf(100);
    //Al metodo escuchable le aadimos una clase anonima de tipo llamable con dos metodos, uno que se ejecutara cuando acabe con exito
    //y otro si no acaba correctamente
    valor.addCallback(new ListenableFutureCallback<Double>() {

        @Override
        public void onSuccess(Double result) {
            System.out.println("El resultado es desde un ListenableFuture: " + result);
        }

        @Override
        public void onFailure(Throwable ex) {
            LOG.log(Level.SEVERE, "Ha ocurrido un error:", ex);
        }
    });
}

From source file:at.tuwien.aic.Main.java

/**
 * Main entry point// w w w  .  j a  v a2s . c  o  m
 *
 * @param args
 */
@SuppressWarnings("empty-statement")
public static void main(String[] args) throws IOException, InterruptedException {

    try {
        System.out.println(new java.io.File(".").getCanonicalPath());
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    TweetCrawler tc = null;

    try {
        tc = TweetCrawler.getInstance();
    } catch (UnknownHostException ex) {
        logger.severe("Could not connect to mongoDb");
        exitWithError(2);
        return;
    }

    int action;

    while (true) {
        action = getDecision("The following actions can be executed",
                new String[] { "Subscribe to topic", "Query topic", "Test preprocessing",
                        "Recreate the evaluation model", "Quit the application" },
                "What action do you want to execute?");

        switch (action) {
        case 1:
            tc.collectTweets(new DefaultTweetHandler() {
                @Override
                public boolean isMatch(String topic) {
                    return true;
                }
            }, getNonEmptyString(
                    "Which topic do you want to subscribe to (use spaces to specify more than one keyword)?")
                            .split(" "));

            System.out.println("Starting to collection tweets");
            System.out.println("Press enter to quit collecting");

            while (System.in.read() != 10)
                ;

            tc.stopCollecting();

            break;
        case 2:
            classifyTopic();
            break;
        case 3: {
            int subAction = getDecision("The following preprocessing steps are available",
                    new String[] { "Stop word removal", "Stemming", "Both" }, "What do you want to test?");

            switch (subAction) {
            case 1:
                stopWords();
                break;
            case 2:
                stem();
                break;
            case 3:
                stem(stopWords());
            default:
                break;
            }

            break;
        }
        case 4: {
            ClassifyTweet.saveModel("resources/traindata.arff", "resources/classifier.model");
            break;
        }
        case 5:
            exit();
        case 6: {
            ClassifyTweet.saveModel("resources/traindata.arff", "resources/classifier.model");
            Classifier c = ClassifyTweet.loadModel("resources/classifier.model");
            ClassifyTweet.classifyTweetArff(c, "resources/unlabeled.arff");
            //ClassifyTweet.evaluate(c, "resources/traindata.arff");
            break;
        }
        }
    }
}

From source file:com.rest.samples.getTipoCambioBanxico.java

public static void main(String[] args) {
    String url = "http://www.banxico.org.mx/tipcamb/llenarTiposCambioAction.do?idioma=sp";
    try {//from  w ww .java2  s  . c  o  m
        HttpClient hc = HttpClientBuilder.create().build();
        HttpGet request = new HttpGet(url);
        request.setHeader("User-Agent", "Mozilla/5.0");
        request.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

        HttpResponse res = hc.execute(request);
        if (res.getStatusLine().getStatusCode() != 200) {
            throw new RuntimeException("Failed : HTTP eror code: " + res.getStatusLine().getStatusCode());
        }

        BufferedReader rd = new BufferedReader(new InputStreamReader(res.getEntity().getContent()));
        StringBuffer result = new StringBuffer();
        String line = "";
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }
        Document doc = Jsoup.parse(result.toString());
        Element tipoCambioFix = doc.getElementById("FIX_DATO");
        System.out.println(tipoCambioFix.text());

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

From source file:com.mmone.gpdati.allotment.reader.AllotmentFileReader.java

public static void main(String[] args) {
    try {// w  w  w. j  a  va 2 s  .c o  m
        AllotmentLineProvvider afr = new AllotmentFileReader(
                "C:/svnprjects/mauro_netbprj/abs-ota-soapui-listener/test/FILE_DISPO__20160616.txt");

        List<String> l = afr.getLines();
        for (String s : l) {
            System.out.println(s);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
    } catch (Exception ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:hms.hwestra.interactionrebuttal.InteractionRebuttal.java

/**
 * @param args the command line arguments
 *//*from  w  w  w .j  av a  2 s .  c om*/
public static void main(String[] args) {

    InteractionRebuttal r = new InteractionRebuttal();
    try {
        r.run();
        // TODO code application logic here
    } catch (IOException ex) {
        Logger.getLogger(InteractionRebuttal.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.rest.samples.getReportFromJasperServer.java

public static void main(String[] args) {
    // TODO code application logic here
    String url = "http://username:password@10.49.28.3:8081/jasperserver/rest_v2/reports/Reportes/vencimientos.pdf?feini=2016-09-30&fefin=2016-09-30";
    try {//from   w w w .  ja v a 2s  . c o  m
        HttpClient hc = HttpClientBuilder.create().build();
        HttpGet getMethod = new HttpGet(url);
        getMethod.addHeader("accept", "application/pdf");
        HttpResponse res = hc.execute(getMethod);
        if (res.getStatusLine().getStatusCode() != 200) {
            throw new RuntimeException("Failed : HTTP eror code: " + res.getStatusLine().getStatusCode());
        }

        InputStream is = res.getEntity().getContent();
        OutputStream os = new FileOutputStream(new File("vencimientos.pdf"));
        int read = 0;
        byte[] bytes = new byte[2048];

        while ((read = is.read(bytes)) != -1) {
            os.write(bytes, 0, read);
        }
        is.close();
        os.close();

        if (Desktop.isDesktopSupported()) {
            File pdfFile = new File("vencimientos.pdf");
            Desktop.getDesktop().open(pdfFile);
        }

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

From source file:fr.logfiletoes.Main.java

public static void main(String[] args) throws IOException {
    String configFile = getConfigFilePath();

    LOG.log(Level.INFO, "Load config file \"{0}\"", configFile);
    Config config = new Config(configFile);
    LOG.info("Config file OK");

    for (Unit unit : config.getUnits()) {
        unit.start();/*from  w ww . j a v a  2 s  .  c o m*/
    }

    while (true) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:bookChapter.theoretical.AnalyzeTheoreticalMSMSCalculation.java

/**
 *
 * @param args//w ww.  j  av a 2  s.  com
 * @throws IOException
 * @throws FileNotFoundException
 * @throws ClassNotFoundException
 * @throws InterruptedException
 * @throws MzMLUnmarshallerException
 */
public static void main(String[] args) throws IOException, FileNotFoundException, ClassNotFoundException,
        IOException, InterruptedException, MzMLUnmarshallerException {
    Logger l = Logger.getLogger("AnalyzeTheoreticalMSMSCalculation");
    Date date = Calendar.getInstance().getTime();
    DateFormat formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy, hh:mm:ss.SSS a");
    String now = formatter.format(date);
    l.log(Level.INFO, "Calculation starts at {0}", now);
    double precursorTolerance = ConfigHolder.getInstance().getDouble("precursor.tolerance"),
            fragmentTolerance = ConfigHolder.getInstance().getDouble("fragment.tolerance");
    String databaseName = ConfigHolder.getInstance().getString("database.name"),
            spectraName = ConfigHolder.getInstance().getString("spectra.name"),
            output = ConfigHolder.getInstance().getString("output");
    int correctionFactor = ConfigHolder.getInstance().getInt("correctionFactor");
    boolean theoFromAllCharges = ConfigHolder.getInstance().getBoolean("hasAllPossCharge");
    BufferedWriter bw = new BufferedWriter(new FileWriter(output));
    bw.write("SpectrumTitle" + "\t" + "PrecursorMZ" + "\t" + "PrecursorCharge" + "\t" + "Observed Mass (M+H)"
            + "\t" + "AndromedaLikeScore" + "\t" + "SequestLikeScore" + "\t" + "PeptideByAndromedaLikeScore"
            + "\t" + "PeptideBySequestLikeScore" + "\t" + "LevenshteinDistance" + "\t" + "TotalScoredPeps"
            + "\t" + "isCorrectMatchByAndromedaLike" + "\t" + "isCorrectMatchBySequestLikeScore" + "\n");
    l.info("Getting database entries");
    // first load all sequences into the memory 
    HashSet<DBEntry> dbEntries = getDBEntries(databaseName);
    // for every spectrum-calculate both score...
    // now convert to binExperimental spectrum
    int num = 0;
    SpectrumFactory fct = SpectrumFactory.getInstance();
    num = 0;
    File f = new File(spectraName);
    if (spectraName.endsWith(".mgf")) {
        fct.addSpectra(f, new WaitingHandlerCLIImpl());
        l.log(Level.INFO, "Spectra scoring starts at {0}", now);
        for (String title : fct.getSpectrumTitles(f.getName())) {
            num++;
            MSnSpectrum ms = (MSnSpectrum) fct.getSpectrum(f.getName(), title);
            // here calculate all except this is an empty spectrum...
            if (ms.getPeakList().size() > 2) {
                // to check a spectrum with negative values..
                String text = result(ms, precursorTolerance, dbEntries, fragmentTolerance, correctionFactor,
                        theoFromAllCharges);
                if (!text.isEmpty()) {
                    bw.write(text);
                }
            }
            if (num % 500 == 0) {
                l.info("Running " + num + " spectra." + Calendar.getInstance().getTime());
            }
        }
    }
    l.info("Program finished at " + Calendar.getInstance().getTime());

    bw.close();
}

From source file:checkchansourcedata.CheckChanSourceData.java

/**
 * @param args the command line arguments
 *//*from  w  w w  .  j a va 2s .  c  o  m*/
public static void main(String[] args) {
    CheckChanSourceData me = new CheckChanSourceData();
    try {
        if (me.parseCommand(args, me.getClass().getSimpleName(), "0.0.1")) {
            me.go();
        }
    } catch (Exception ex) {
        Logger.getLogger(CheckChanSourceData.class.getName()).log(Level.SEVERE, null, ex);
    }
}