Example usage for java.util.logging Logger info

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

Introduction

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

Prototype

public void info(Supplier<String> msgSupplier) 

Source Link

Document

Log a INFO message, which is only to be constructed if the logging level is such that the message will actually be logged.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    Logger logger = Logger.getLogger("DeviceLog");

    logger.info("<Device id=\"99\"/>");
}

From source file:MainClass.java

public static void main(String[] args) {
    Logger logger = Logger.getLogger("com.java2s.log");

    logger.severe("severe");
    logger.warning("warning");
    logger.info("info");
    logger.config("config");
    logger.fine("fine");
    logger.finer("finer");
    logger.finest("value =" + 42);
}

From source file:Logging.java

public static void main(String[] args) {
    Logger log = Logger.getLogger("global");

    log.finest("A");
    log.finer("B");
    log.fine("C");
    log.config("D");
    log.info("E");
    log.warning("O");
    log.severe("A");
}

From source file:org.cloudfoundry.workers.stocks.integration.client.Main.java

public static void main(String args[]) throws Throwable {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
    annotationConfigApplicationContext.getEnvironment().setActiveProfiles(isCloudFoundry() ? "cloud" : "local");
    annotationConfigApplicationContext.scan(ClientConfiguration.class.getPackage().getName());
    annotationConfigApplicationContext.refresh();

    StockClientGateway clientGateway = annotationConfigApplicationContext.getBean(StockClientGateway.class);
    Logger log = Logger.getLogger(Main.class.getName());
    String symbol = "VMW";
    StockSymbolLookup lookup = clientGateway.lookup(symbol);
    log.info("client: retrieved stock information: " + ToStringBuilder.reflectionToString(lookup));

}

From source file:MyHtmlFormatter.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger("com.mycompany");
    FileHandler fh = new FileHandler("mylog.html");
    fh.setFormatter(new MyHtmlFormatter());
    logger.addHandler(fh);/*  w ww  .j a  va2  s. c  o  m*/

    logger.setLevel(Level.ALL);
    logger.severe("my severe message");
    logger.info("my info message");
    logger.entering("Main class", "myMethod", new Object[] { "para1", "para2" });
}

From source file:MainClass.java

public static void main(String args[]) {

    Logger logger = Logger.getLogger("my.log");

    Handler handler = null;// w ww .j av a 2  s  .  c o m

    try {
        handler = new FileHandler("messages.log");
    } catch (IOException e) {
        System.out.println("Could not create file. Using the console handler");
        handler = new ConsoleHandler();
    }

    logger.addHandler(handler);

    handler.setFormatter(new XMLFormatter());

    logger.info("Our first logging message");
    logger.severe("Something terrible happened");
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger("com.mycompany");
    FileHandler fh = new FileHandler("mylog.txt");
    fh.setFormatter(new SimpleFormatter());
    logger.addHandler(fh);//from  w  w  w  . ja  v  a 2 s. c o m

    // fh = new FileHandler("mylog.xml");
    // fh.setFormatter(new XMLFormatter());
    // logger.addHandler(fh);

    // Log a few messages
    logger.severe("my severe message");
    logger.warning("my warning message");
    logger.info("my info message");
    logger.config("my config message");
    logger.fine("my fine message");
    logger.finer("my finer message");
    logger.finest("my finest message");
}

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   ww w .j av  a  2 s .c o m
    }

    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:NewApplication.java

/**
 * @param args the command line arguments
 *//*from w ww .j a va 2s . com*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>

    Logger log = Logger.getLogger("NewApplication");
    try {
        FileInputStream fis = new FileInputStream("p.properties");
        LogManager.getLogManager().readConfiguration(fis);
        log.setLevel(Level.FINE);
        log.addHandler(new java.util.logging.ConsoleHandler());
        log.setUseParentHandlers(false);

        log.info("starting NewApplication");
        fis.close();
    } catch (Exception e) {
    }
    ;

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewApplication().setVisible(true);
        }
    });
}

From source file:bookChapter.theoretical.AnalyzeTheoreticalMSMSCalculation.java

/**
 *
 * @param args// ww w  . ja  v  a  2 s . co  m
 * @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();
}