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

public static void main(String args[]) throws Exception {
    LogManager lm = LogManager.getLogManager();
    Logger logger;/* w  w w  . java2 s  .c  o m*/
    FileHandler fh = new FileHandler("log_test.txt");

    logger = Logger.getLogger("LoggingExample1");

    lm.addLogger(logger);
    logger.setLevel(Level.INFO);
    fh.setFormatter(new XMLFormatter());

    logger.addHandler(fh);
    //logger.setUseParentHandlers(false);
    logger.log(Level.INFO, "test 1");
    logger.log(Level.INFO, "test 2");
    logger.log(Level.INFO, "test 3");
    fh.close();
}

From source file:LoggingExample1.java

public static void main(String args[]) {
    try {// www. ja  v  a2s. co m
        LogManager lm = LogManager.getLogManager();
        Logger logger;
        FileHandler fh = new FileHandler("log_test.txt");

        logger = Logger.getLogger("LoggingExample1");

        lm.addLogger(logger);
        logger.setLevel(Level.INFO);
        fh.setFormatter(new XMLFormatter());

        logger.addHandler(fh);
        //logger.setUseParentHandlers(false);
        logger.log(Level.INFO, "test 1");
        logger.log(Level.INFO, "test 2");
        logger.log(Level.INFO, "test 3");
        fh.close();
    } catch (Exception e) {
        System.out.println("Exception thrown: " + e);
        e.printStackTrace();
    }
}

From source file:br.com.fabianoabreu.sendEmail.EnvioTest.java

public static void main(String[] args) {

    Email envio = new Email();
    try {/*from w  w  w  .j  av a2 s .c om*/
        envio.sendEmail();
    } catch (EmailException ex) {
        Logger.getLogger(EnvioTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ru.elcor.mis.scheduler.point.EndPoint.java

public static void main(String[] args) {
    try {/*from w  ww . j  av a2  s.  c om*/
        doit();
    } catch (InterruptedException ex) {
        Logger.getLogger(EndPoint.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:model.TestJSON.java

public static void main(String[] Args) {
    try {/*  w w  w.  ja  v  a  2  s  . c o  m*/
        JSONObject jo = new JSONObject();
        jo.put("num_sala", 1);
        jo.put("num_tavolo", 2);
        jo.put("num_commensali", 10);
        jo.put("id_ordine", 10222);
        System.out.println(jo.toString());
    } catch (JSONException ex) {
        Logger.getLogger(TestJSON.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.bigdata.hbaseConsultor.Consultor.java

/**
 * @param args the command line arguments
 */// w  w  w .ja va2s.c o  m
public static void main(String[] args) {
    String table = "syslog";
    HBase hb = new HBase(new GenericObjectPool<>(new ConexionFactory()), "syslog");
    try {
        hb.getFilterRows();
    } catch (Exception ex) {
        Logger.getLogger(Consultor.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:minecrunch_updater.Minecrunch_updater.java

/**
 * @param args the command line arguments
 *//*  w  ww  .j a va 2s  .c  o m*/
public static void main(String[] args) {
    try {
        VersionCheck();
    } catch (MalformedURLException ex) {
        Logger.getLogger(Minecrunch_updater.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:medical.Medical.java

/**
 * @param args the command line arguments
 *///w w  w . j a  v  a  2  s. co m

public static void main(String[] args) throws IOException, ClientProtocolException, JSONException {
    // TODO code application logic here

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException ex) {
        Logger.getLogger(Medical.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(Medical.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(Medical.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(Medical.class.getName()).log(Level.SEVERE, null, ex);
    }
    FrameCita cita = new FrameCita();
    cita.setVisible(true);
}

From source file:edu.eci.arsw.aop.spring.idol.MainProgram.java

/**
 * @param args the command line arguments
 *//* www .  ja  v a 2s .  c  o  m*/
public static void main(String[] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("spring-simple-idol.xml");
    Performer pf = (Performer) ac.getBean("eddie");
    try {
        pf.perform();
    } catch (PerformanceException ex) {
        Logger.getLogger(MainProgram.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:eu.europeana.datamigration.ese2edm.LogCleaner.java

public static void main(String[] args) {
    try {//  w w  w . j ava 2 s. c  o m
        List<String> lines = FileUtils.readLines(new File("/home/gmamakis/test.log"));
        List<String> newLines = new ArrayList<String>();
        for (String line : lines) {
            if (!line.startsWith("Apr")) {
                newLines.add(line);
            }
        }
        FileUtils.writeLines(new File("/home/gmamakis/rdfslabel.log"), newLines);
    } catch (IOException ex) {
        Logger.getLogger(LogCleaner.class.getName()).log(Level.SEVERE, null, ex);
    }
}