Example usage for java.util.logging Level INFO

List of usage examples for java.util.logging Level INFO

Introduction

In this page you can find the example usage for java.util.logging Level INFO.

Prototype

Level INFO

To view the source code for java.util.logging Level INFO.

Click Source Link

Document

INFO is a message level for informational messages.

Usage

From source file:com.itcs.commons.email.impl.NoReplySystemMailSender.java

/**
 *
 * @param to//w  w  w  .j a  va 2 s .c om
 * @param subject
 * @param body
 * @param attachments
 * @throws EmailException
 */
public static void sendHTML(String[] to, String subject, String body, List<EmailAttachment> attachments)
        throws EmailException {
    try {
        getExecutorService().execute(new RunnableSendHTMLEmail(getSession(), to, subject, body, attachments));
    } catch (NamingException ex) {
        Logger.getLogger(NoReplySystemMailSender.class.getName()).log(Level.INFO,
                "El nombre jndi de la session de email esta mal configurado!!", ex);
        throw new EmailException("El nombre jndi de la session de email esta mal configurado!!");
    }
}

From source file:de.blinkenlights.bmix.main.Daemon.java

public void init(DaemonContext arg0) throws Exception {
    int verbosity = 1;
    if (System.getProperty("debugLevel") != null) {
        verbosity = Integer.parseInt(System.getProperty("debugLevel"));
    }/*from   w w w . ja va2s  . c  om*/
    Level logLevel;
    if (verbosity == 0) {
        logLevel = Level.WARNING;
    } else if (verbosity == 1) {
        logLevel = Level.INFO;
    } else if (verbosity == 2) {
        logLevel = Level.FINE;
    } else if (verbosity >= 3) {
        logLevel = Level.FINEST;
    } else {
        System.err.println("Fatal Error: Invalid log verbosity: " + verbosity);
        return;
    }
    System.err.println("Setting log level to " + logLevel);
    Logger.getLogger("").setLevel(logLevel);
    for (Handler handler : Logger.getLogger("").getHandlers()) {
        handler.setLevel(logLevel);
    }

    bmix = new BMix("bmix.xml", false);
}

From source file:net.chrissearle.spring.twitter.spring.Twitter4jUserExistanceService.java

public boolean checkIfUserExists(String twitterId) {
    boolean userExists = true;

    if (logger.isLoggable(Level.INFO)) {
        logger.info(new StringBuilder().append("Asking for: ").append(twitterId).toString());
    }//  w w w.  j  a  va 2 s. c  o m

    if (isActive()) {
        userExists = askTwitterForUser(twitterId);
    }

    return userExists;
}

From source file:com.sifiso.dvs.util.DocFileUtil.java

public ResponseDTO downloadPDF(HttpServletRequest request, PlatformUtil platformUtil)
        throws FileUploadException {
    logger.log(Level.INFO, "######### starting PDF DOWNLOAD process\n\n");
    ResponseDTO resp = new ResponseDTO();
    InputStream stream = null;/*from ww w.  j av a  2  s  .  c o m*/
    File rootDir;
    try {
        rootDir = dvsProperties.getDocumentDir();
        logger.log(Level.INFO, "rootDir - {0}", rootDir.getAbsolutePath());
        if (!rootDir.exists()) {
            rootDir.mkdir();
        }
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Properties file problem", ex);
        resp.setMessage("Server file unavailable. Please try later");
        resp.setStatusCode(114);

        return resp;
    }

    PatientfileDTO dto = null;
    Gson gson = new Gson();
    File clientDir = null, surgeryDir = null, doctorDir = null;
    try {
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            String name = item.getFieldName();
            stream = item.openStream();
            if (item.isFormField()) {
                if (name.equalsIgnoreCase("JSON")) {
                    String json = Streams.asString(stream);
                    if (json != null) {
                        logger.log(Level.INFO, "picture with associated json: {0}", json);
                        dto = gson.fromJson(json, PatientfileDTO.class);
                        if (dto != null) {
                            surgeryDir = createSurgeryFileDirectory(rootDir, surgeryDir,
                                    dto.getDoctor().getSurgeryID());
                            if (dto.getDoctorID() != null) {
                                doctorDir = createDoctorDirectory(surgeryDir, doctorDir, dto.getDoctorID());
                                if (dto.getClientID() != null) {
                                    clientDir = createClientDirectory(doctorDir, clientDir);
                                }
                            }

                        }
                    } else {
                        logger.log(Level.WARNING, "JSON input seems pretty fucked up! is NULL..");
                    }
                }
            } else {
                File imageFile = null;
                if (dto == null) {
                    continue;
                }
                DateTime dt = new DateTime();
                String fileName = "";

                if (dto.getClientID() != null) {
                    fileName = "client" + dto.getClientID() + ".pdf";
                }

                imageFile = new File(clientDir, fileName);

                writeFile(stream, imageFile);
                resp.setStatusCode(0);
                resp.setMessage("Photo downloaded from mobile app ");
                //add database
                System.out.println("filepath: " + imageFile.getAbsolutePath());

            }
        }

    } catch (FileUploadException | IOException | JsonSyntaxException ex) {
        logger.log(Level.SEVERE, "Servlet failed on IOException, images NOT uploaded", ex);
        throw new FileUploadException();
    }

    return resp;
}

From source file:com.jsmartframework.web.manager.TagEncrypter.java

static void init() {
    try {/* w  ww .  j  a  v  a  2 s. c  om*/
        String customKey = CONFIG.getContent().getTagSecretKey();
        if (StringUtils.isNotBlank(customKey)) {

            if (customKey.length() != CYPHER_KEY_LENGTH) {
                throw new RuntimeException("Custom tag-secret-key must have its value " + "with ["
                        + CYPHER_KEY_LENGTH + "] characters");
            }
            secretKey = new SecretKeySpec(customKey.getBytes("UTF8"), "AES");
        } else {
            secretKey = new SecretKeySpec(DEFAULT_KEY.getBytes("UTF8"), "AES");
        }
    } catch (UnsupportedEncodingException ex) {
        LOGGER.log(Level.INFO, "Failed to generate key secret for tag: " + ex.getMessage());
    }
}

From source file:br.gov.sc.fatma.resourcemanager.commands.SiteCheckIfUPCommand.java

@Override
public Status execute() {
    Logger.getLogger(SiteCheckIfUPCommand.class.getName()).log(Level.FINE,
            "-------- " + _site.getPath() + " Connection Testing ------");
    Status result;// w  w w  .  j a va 2 s  .  c om
    CloseableHttpClient httpclient = HttpClients.createDefault();
    try {
        HttpGet httpget = new HttpGet(_site);
        Logger.getLogger(SiteCheckIfUPCommand.class.getName()).log(Level.INFO,
                "Executing request " + httpget.getRequestLine());

        ResponseHandler<String> responseHandler = new BasicResponseHandler() {
            @Override
            public String handleResponse(final HttpResponse response)
                    throws ClientProtocolException, IOException {
                int status = response.getStatusLine().getStatusCode();
                if (status >= 200 && status < 300) {
                    return "200";
                } else {
                    return String.valueOf(status);
                }
            }
        };
        String responseBody = httpclient.execute(httpget, responseHandler);
        result = new Status(responseBody.equals("200"), "", Integer.valueOf(responseBody));
    } catch (IOException ex) {
        Logger.getLogger(SiteCheckIfUPCommand.class.getName()).log(Level.WARNING, ex.getMessage(), ex);
        ex.printStackTrace();
        result = new Status(false, ex.getMessage(), -1);
    } finally {
        try {
            httpclient.close();
        } catch (IOException ex) {
        }
    }

    return result;
}

From source file:net.chrissearle.spring.twitter.spring.Twitter4jDirectMessageService.java

public void dm(String userName, String message) {
    if (logger.isLoggable(Level.INFO)) {
        logger.info(new StringBuilder().append("DM to ").append(userName).append(" with text ").append(message)
                .toString());/* w ww .  ja v a 2s.c  o m*/
    }

    if (isActive()) {
        sendMessage(userName, message);
    } else {
        if (logger.isLoggable(Level.INFO)) {
            logger.info("Twitter disabled");
        }
    }
}

From source file:com.betel.flowers.web.bean.util.UploadFileRun.java

@Override
public void run() {
    Boolean succesefull = Boolean.FALSE;
    Path path = Paths.get(url);
    //if directory exists?
    if (!Files.exists(path)) {
        try {//  w ww .  j a  va2  s  .  c  o m
            Files.createDirectories(path);
            log.log(Level.INFO, "Directory is created!");
        } catch (IOException e) {
            //fail to create directory
            log.log(Level.SEVERE, "Failed to create directory! " + e.getMessage());
        }
    }

    File fileDelete = new File(url + name + "." + ext);
    if (fileDelete.delete()) {
        log.log(Level.INFO, "Se elimino el archivo: " + url + name + "." + ext);
    } else {
        log.log(Level.INFO, "No se elimino el archivo: " + url + name + "." + ext);
    }

    File file = new File(url + name + "." + ext);
    try {
        byte[] imgbytes = IOUtils.toByteArray(input);
        InputStream in = new ByteArrayInputStream(imgbytes);
        BufferedImage bImageFromConvert = ImageIO.read(in);
        ImageIO.write(bImageFromConvert, ext, file);
        succesefull = Boolean.TRUE;
    } catch (IOException e) {
        log.log(Level.SEVERE, "Error al guardar la imagen en:" + file.getPath(), e);
    }
    if (succesefull) {
        try {
            this.finalize();
            this.exito = true;
        } catch (Throwable ex) {
            log.log(Level.SEVERE, "Error al procesar imagen", ex);
        }
    } else {
        this.interrupt();
        this.exito = false;
    }
}

From source file:com.okmich.hackerday.client.tool.ClientSimulator.java

@Override
public void run() {
    //read file content
    LineIterator lIt;/*from  w  ww.  ja  v  a 2  s .c om*/
    try {
        LOG.log(Level.INFO, "Reading the content of file");
        lIt = FileUtils.lineIterator(this.file);
    } catch (IOException ex) {
        Logger.getLogger(ClientSimulator.class.getName()).log(Level.SEVERE, null, ex);
        throw new RuntimeException(ex);
    }
    String line;
    LOG.log(Level.INFO, "Sending file content to kafka topic - {0}", this.topic);
    while (lIt.hasNext()) {
        line = lIt.nextLine();
        //send message to kafka
        this.kafkaMessageProducer.send(this.topic, line);
        try {
            Thread.currentThread().sleep(this.random.nextInt(1000));
        } catch (InterruptedException ex) {
            Logger.getLogger(ClientSimulator.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.sifiso.dvs.util.PhotoUtil.java

public ResponseDTO downloadPhotos(HttpServletRequest request, PlatformUtil platformUtil)
        throws FileUploadException {
    logger.log(Level.INFO, "######### starting PHOTO DOWNLOAD process\n\n");
    ResponseDTO resp = new ResponseDTO();
    InputStream stream = null;//from   w  w w.j  av a2 s  .  c o m
    File rootDir;
    try {
        rootDir = dvsProperties.getImageDir();
        logger.log(Level.INFO, "rootDir - {0}", rootDir.getAbsolutePath());
        if (!rootDir.exists()) {
            rootDir.mkdir();
        }
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Properties file problem", ex);
        resp.setMessage("Server file unavailable. Please try later");
        resp.setStatusCode(114);

        return resp;
    }

    PhotoUploadDTO dto = null;
    Gson gson = new Gson();
    File doctorFileDir = null, surgeryDir = null;
    try {
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(request);
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            String name = item.getFieldName();
            stream = item.openStream();
            if (item.isFormField()) {
                if (name.equalsIgnoreCase("JSON")) {
                    String json = Streams.asString(stream);
                    if (json != null) {
                        logger.log(Level.INFO, "picture with associated json: {0}", json);
                        dto = gson.fromJson(json, PhotoUploadDTO.class);
                        if (dto != null) {
                            surgeryDir = createSurgeryFileDirectory(rootDir, surgeryDir, dto.getSurgeryID());
                            if (dto.getDoctorID() > 0) {
                                doctorFileDir = createDoctorDirectory(surgeryDir, doctorFileDir,
                                        dto.getDoctorID());
                            }

                        }
                    } else {
                        logger.log(Level.WARNING, "JSON input seems pretty fucked up! is NULL..");
                    }
                }
            } else {
                File imageFile = null;
                if (dto == null) {
                    continue;
                }
                DateTime dt = new DateTime();
                String fileName = "";
                if (dto.isIsFullPicture()) {
                    fileName = "f" + dt.getMillis() + ".jpg";
                } else {
                    fileName = "t" + dt.getMillis() + ".jpg";
                }
                if (dto.getPatientfileID() != null) {
                    if (dto.isIsFullPicture()) {
                        fileName = "f" + dto.getPatientfileID() + ".jpg";
                    } else {
                        fileName = "t" + dto.getPatientfileID() + ".jpg";
                    }
                }

                //
                switch (dto.getPictureType()) {
                case PhotoUploadDTO.FILES_DOCTOR:
                    imageFile = new File(doctorFileDir, fileName);
                    break;
                case PhotoUploadDTO.FILES_SURGERY:
                    imageFile = new File(surgeryDir, fileName);
                }

                writeFile(stream, imageFile);
                resp.setStatusCode(0);
                resp.setMessage("Photo downloaded from mobile app ");
                //add database
                System.out.println("filepath: " + imageFile.getAbsolutePath());
                //create uri
                /*int index = imageFile.getAbsolutePath().indexOf("monitor_images");
                 if (index > -1) {
                 String uri = imageFile.getAbsolutePath().substring(index);
                 System.out.println("uri: " + uri);
                 dto.setUri(uri);
                 }
                 dto.setDateUploaded(new Date());
                 if (dto.isIsFullPicture()) {
                 dto.setThumbFlag(null);
                 } else {
                 dto.setThumbFlag(1);
                 }
                 dataUtil.addPhotoUpload(dto);*/

            }
        }

    } catch (FileUploadException | IOException | JsonSyntaxException ex) {
        logger.log(Level.SEVERE, "Servlet failed on IOException, images NOT uploaded", ex);
        throw new FileUploadException();
    }

    return resp;
}