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.utfpr.edu.br.agenda.ServicoMail.EnviaEmailSimpleMail.java

public void envio(String destino) {
    Email email = new SimpleEmail();

    try {/*from w ww . j a  v  a  2  s  .c  om*/
        email.setSubject("Teste de Envio com Simple Mail");
        email.addTo(destino);
        email.setMsg("Est na hora de realizar a manuteno do seu carro. Verifique os itens!");
        mailer.send(email);
    } catch (EmailException ex) {
        System.out.println("Erro ao enviar com Simple Mail.");
        Logger.getLogger(EnviaEmailSimpleMail.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.iselect.kernal.geo.validator.CountryCodeValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext cvt) {
    try {/* ww w  .  j a  v  a  2  s.  c o m*/
        geoService.getCountryByCode(value);
    } catch (EntityNotFoundException ex) {
        return true;
    } catch (CopyPropertiesException ex) {
        Logger.getLogger(CountryCodeValidator.class.getName()).log(Level.SEVERE, null, ex);
        throw new RuntimeException(ex);
    }
    return false;
}

From source file:at.ac.tuwien.dsg.cloudlyra.utils.RestfulWSClient.java

public RestfulWSClient(String ip, String port, String resource) {
    this.ip = ip;
    this.port = port;
    this.resource = resource;
    url = "http://" + ip + ":" + port + resource;
    logger = Logger.getLogger(this.getClass().getName());
}

From source file:br.edimarmanica.weir2.rule.type.RulesDataTypeController.java

/**
 * Persiste the datatype of each rule/*from  w  w  w.  j a  v a  2  s  .co  m*/
 *
 * @param site
 */
public static void persiste(Site site) {
    Map<String, DataType> ruleType = new HashMap<>();

    File dirInput = new File(Paths.PATH_INTRASITE + "/" + site.getPath() + "/extracted_values");
    for (File rule : dirInput.listFiles()) {
        ruleType.put(rule.getName(), RuleDataType.getMostFrequentType(rule));
    }

    File dirOutput = new File(Paths.PATH_WEIR_V2 + "/" + site.getPath());
    dirOutput.mkdirs();

    File file = new File(dirOutput.getAbsolutePath() + "/types.csv");
    String[] HEADER = { "RULE", "TYPE" };
    CSVFormat format = CSVFormat.EXCEL.withHeader(HEADER);

    try (Writer out = new FileWriter(file)) {
        try (CSVPrinter csvFilePrinter = new CSVPrinter(out, format)) {
            for (String rule : ruleType.keySet()) {
                List<String> dataRecord = new ArrayList<>();
                dataRecord.add(rule);
                dataRecord.add(ruleType.get(rule).name());
                csvFilePrinter.printRecord(dataRecord);
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(RulesDataTypeController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.me.DAO.DAO.java

public Connection getConnection() throws SQLException {
    Connection conn = null;/*w ww  . j  a  va2 s.c  o m*/

    try {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(dburl, dbuser, dbpassword);
    } catch (SQLException ex) {
        Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return conn;
}

From source file:com.ut.healthelink.jobs.processOutputRecords.java

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    try {/*from  w ww .j ava  2s. c om*/
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

        transactionOutManager.selectOutputRecordsForProcess(0);
    } catch (Exception ex) {
        try {
            throw new Exception("Error occurred trying to process output records from schedule task", ex);
        } catch (Exception ex1) {
            Logger.getLogger(processOutputRecords.class.getName()).log(Level.SEVERE, null, ex1);
        }
    }

}

From source file:jshm.logging.Log.java

public static void reloadConfig() throws Exception {
    // all logging
    Handler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(DEBUG ? Level.ALL : Level.WARNING);
    consoleHandler.setFormatter(new OneLineFormatter());

    Logger cur = Logger.getLogger("");
    removeHandlers(cur);/*ww w  . ja va 2  s  . c o m*/

    cur.addHandler(consoleHandler);

    // jshm logging
    Formatter fileFormatter = new FileFormatter();
    Handler jshmHandler = new FileHandler("data/logs/JSHManager.txt");
    jshmHandler.setLevel(Level.ALL);
    jshmHandler.setFormatter(fileFormatter);

    cur = Logger.getLogger("jshm");
    cur.addHandler(jshmHandler);
    cur.setLevel(DEBUG ? Level.ALL : Level.INFO);

    // hibernate logging
    Handler hibernateHandler = new FileHandler("data/logs/Hibernate.txt");
    hibernateHandler.setLevel(Level.ALL);
    hibernateHandler.setFormatter(fileFormatter);

    cur = Logger.getLogger("org.hibernate");
    removeHandlers(cur);

    cur.addHandler(hibernateHandler);
    cur.setLevel(DEBUG ? Level.INFO : Level.WARNING);

    // HttpClient logging
    Handler httpClientHandler = new FileHandler("data/logs/HttpClient.txt");
    httpClientHandler.setLevel(Level.ALL);
    httpClientHandler.setFormatter(fileFormatter);

    //      cur = Logger.getLogger("httpclient.wire");
    cur = Logger.getLogger("httpclient.wire.header");
    removeHandlers(cur);

    cur.addHandler(httpClientHandler);
    cur.setLevel(DEBUG ? Level.ALL : Level.INFO);

    cur = Logger.getLogger("org.apache.commons.httpclient");
    removeHandlers(cur);

    cur.addHandler(httpClientHandler);
    cur.setLevel(DEBUG ? Level.FINER : Level.INFO);

    // HtmlParser logging
    Handler htmlParserHandler = new FileHandler("data/logs/HtmlParser.txt");
    htmlParserHandler.setLevel(Level.ALL);
    htmlParserHandler.setFormatter(fileFormatter);

    cur = Logger.getLogger("org.htmlparser");
    removeHandlers(cur);

    cur.addHandler(htmlParserHandler);
    cur.setLevel(DEBUG ? Level.ALL : Level.INFO);

    // SwingX logging
    Handler swingxHandler = new FileHandler("data/logs/SwingX.txt");
    swingxHandler.setLevel(Level.ALL);
    swingxHandler.setFormatter(fileFormatter);

    cur = Logger.getLogger("org.jdesktop.swingx");
    removeHandlers(cur);

    cur.addHandler(swingxHandler);
    cur.setLevel(DEBUG ? Level.ALL : Level.INFO);
}

From source file:sachin.spider.Demoss.java

public Demoss(String site) {
    this.site = site;
    try {// ww  w  .  j  a va  2 s . co  m
        this.host = new URL(site).getHost().replaceAll("www.", "");
    } catch (MalformedURLException ex) {
        Logger.getLogger(Demoss.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.netcracker.financeapp.controller.agent.AgentAddServlet.java

@Override
public void init(ServletConfig config) {
    try {//from  www  . j a v a2  s  .c  om
        super.init(config);
        SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());
    } catch (ServletException ex) {
        Logger.getLogger(AgentAddServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ua.epam.kiev.rd.springproject.repository.JdbcCityRepository.java

public Collection<City> getAllCities() {
    try {//from  w  ww.  j  a va  2 s.com
        return this.jdbcTemplate.query("select  CityID, name from city", new CityMapper());
    } catch (DataAccessException e) {
        Logger.getLogger(JdbcCityRepository.class.getName()).log(Level.SEVERE, null, e);
        return null;
    }
}