com.jfinal.log.Log.error()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(284)

本文整理了Java中com.jfinal.log.Log.error()方法的一些代码示例,展示了Log.error()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log.error()方法的具体详情如下:
包路径:com.jfinal.log.Log
类名称:Log
方法名:error

Log.error介绍

暂无

代码示例

代码示例来源:origin: jfinal/jfinal

public static void error(String message) {
  Holder.log.error(message);
}

代码示例来源:origin: jfinal/jfinal

public static void error(String message, Throwable t) {
  Holder.log.error(message, t);
}

代码示例来源:origin: JpressProjects/jpress

protected String httpGet(String url) {
  try {
    return JbootHttpKit.httpGet(url);
  } catch (Exception e) {
    LOGGER.error("httpGet error", e);
  }
  return null;
}

代码示例来源:origin: JpressProjects/jpress

protected String httpPost(String url, Map<String, Object> params) {
  try {
    return JbootHttpKit.httpPost(url, params);
  } catch (Exception e) {
    LOGGER.error("httpGet error", e);
  }
  return null;
}

代码示例来源:origin: JpressProjects/jpress

private static void save(BufferedImage bi, String outputImageFile) {
  try {
    ImageIO.write(bi, getExtName(outputImageFile), new File(outputImageFile));
  } catch (Exception e) {
    log.error(e.toString(), e);
  }
}

代码示例来源:origin: JpressProjects/jpress

public void send(IEmailSender sender) {
  try {
    sender.send(this);
  } catch (Throwable ex) {
    LOG.error(ex.toString(), ex);
  }
}

代码示例来源:origin: JpressProjects/jpress

private Message createMessage() {
  Properties props = new Properties();
  props.setProperty("mail.transport.protocol", "smtp");
  props.setProperty("mail.smtp.auth", "true");
  props.setProperty("mail.smtp.host", host);
  props.setProperty("mail.smtp.port", "25");
  if (useSSL) {
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.smtp.port", "465");
  }
  // error:javax.mail.MessagingException: 501 Syntax: HELO hostname
  props.setProperty("mail.smtp.localhost", "127.0.0.1");
  Session session = Session.getInstance(props, this);
  Message message = new MimeMessage(session);
  try {
    message.setFrom(new InternetAddress(MimeUtility.encodeText(name) + "<" + name + ">"));
  } catch (Exception e) {
    logger.error(e.getMessage(), e);
  }
  return message;
}

代码示例来源:origin: jfinal/jfinal

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
  HttpServletRequest request = (HttpServletRequest)req;
  HttpServletResponse response = (HttpServletResponse)res;
  request.setCharacterEncoding(encoding);
  
  String target = request.getRequestURI();
  if (contextPathLength != 0) {
    target = target.substring(contextPathLength);
  }
  
  boolean[] isHandled = {false};
  try {
    handler.handle(target, request, response, isHandled);
  }
  catch (Exception e) {
    if (log.isErrorEnabled()) {
      String qs = request.getQueryString();
      log.error(qs == null ? target : target + "?" + qs, e);
    }
  }
  
  if (isHandled[0] == false) {
    chain.doFilter(request, response);
  }
}

代码示例来源:origin: JpressProjects/jpress

/**
 * 剪切
 *
 * @param srcImageFile  原图
 * @param destImageFile 存放的目标位置
 * @param left          起始点:左
 * @param top           起始点:上
 * @param width         宽
 * @param height        高
 */
public static void crop(String srcImageFile, String destImageFile, int left, int top, int width, int height) {
  if (notImageExtName(srcImageFile)) {
    throw new IllegalArgumentException("只支持如下几种图片格式:jpg、jpeg、png、bmp");
  }
  try {
    BufferedImage bi = ImageIO.read(new File(srcImageFile));
    width = Math.min(width, bi.getWidth());
    height = Math.min(height, bi.getHeight());
    if (width <= 0) width = bi.getWidth();
    if (height <= 0) height = bi.getHeight();
    left = Math.min(Math.max(0, left), bi.getWidth() - width);
    top = Math.min(Math.max(0, top), bi.getHeight() - height);
    BufferedImage subimage = bi.getSubimage(left, top, width, height);
    BufferedImage resizeImage = resize(subimage, 200, 200);
    save(resizeImage, destImageFile);
  } catch (Exception e) {
    log.error(e.toString(), e);
  }
}

代码示例来源:origin: jfinal/jfinal

private static void startPlugins() {
  List<IPlugin> pluginList = plugins.getPluginList();
  if (pluginList == null) {
    return ;
  }
  
  for (IPlugin plugin : pluginList) {
    try {
      // process ActiveRecordPlugin devMode
      if (plugin instanceof com.jfinal.plugin.activerecord.ActiveRecordPlugin) {
        com.jfinal.plugin.activerecord.ActiveRecordPlugin arp = (com.jfinal.plugin.activerecord.ActiveRecordPlugin)plugin;
        if (arp.getDevMode() == null) {
          arp.setDevMode(constants.getDevMode());
        }
      }
      
      if (plugin.start() == false) {
        String message = "Plugin start error: " + plugin.getClass().getName();
        log.error(message);
        throw new RuntimeException(message);
      }
    }
    catch (Exception e) {
      String message = "Plugin start error: " + plugin.getClass().getName() + ". \n" + e.getMessage();
      log.error(message, e);
      throw new RuntimeException(message, e);
    }
  }
}

代码示例来源:origin: JpressProjects/jpress

return StrUtils.isNotBlank(content) && content.contains("\"Code\":\"OK\"");
} catch (Exception e) {
  log.error("AliyunSmsSender exception", e);

代码示例来源:origin: JpressProjects/jpress

/**
 * @param uploadFile
 * @return new file relative path
 */
public static String moveFile(UploadFile uploadFile) {
  if (uploadFile == null)
    return null;
  File file = uploadFile.getFile();
  if (!file.exists()) {
    return null;
  }
  File newfile = newAttachemnetFile(FileUtils.getSuffix(file.getName()));
  if (!newfile.getParentFile().exists()) {
    newfile.getParentFile().mkdirs();
  }
  try {
    org.apache.commons.io.FileUtils.moveFile(file, newfile);
  } catch (IOException e) {
    LOG.error(e.toString(), e);
  }
  String attachmentRoot = StrUtils.isNotBlank(JPressConfig.me.getAttachmentRoot())
      ? JPressConfig.me.getAttachmentRoot()
      : PathKit.getWebRootPath();
  return FileUtils.removePrefix(newfile.getAbsolutePath(), attachmentRoot);
}

代码示例来源:origin: JpressProjects/jpress

public static void set(String key, String value) {
  if (StrUtils.isBlank(key)) {
    return;
  }
  String oldValue = store.get(key);
  if (Objects.equals(value, oldValue)) {
    return;
  }
  store.put(key, value);
  for (OptionChangeListener listener : LISTENERS) {
    try {
      listener.onChanged(key, value, oldValue);
    } catch (Throwable ex) {
      LOG.error(ex.toString(), ex);
    }
  }
  doFinishedChanged(key, value, oldValue);
}

代码示例来源:origin: JpressProjects/jpress

return true;
} catch (Throwable e) {
  log.error("aliyun oss download error!!!  path:" + path + "   toFile:" + toFile, e);
  if (toFile.exists()) {
    toFile.delete();

代码示例来源:origin: JpressProjects/jpress

public void detail() {
  Long id = getIdPara();
  Attachment attachment = as.findById(id);
  setAttr("attachment", attachment);
  File attachmentFile = new File(PathKit.getWebRootPath(), attachment.getPath());
  setAttr("attachmentName", attachmentFile.getName());
  long fileLen = attachmentFile.length();
  String fileLenUnit = "Byte";
  if (fileLen > 1024) {
    fileLen = fileLen / 1024;
    fileLenUnit = "KB";
  }
  if (fileLen > 1024) {
    fileLen = fileLen / 1024;
    fileLenUnit = "MB";
  }
  setAttr("attachmentSize", fileLen + fileLenUnit);
  try {
    if (AttachmentUtils.isImage(attachment.getPath())) {
      String ratio = ImageUtils.ratioAsString(attachmentFile.getAbsolutePath());
      setAttr("attachmentRatio", ratio == null ? "unknow" : ratio);
    }
  } catch (Throwable e) {
    LOG.error("detail() ratioAsString error", e);
  }
  render("attachment/detail.html");
}

代码示例来源:origin: jfinal/jfinal

if (log.isErrorEnabled()) {
  String qs = request.getQueryString();
  log.error(errorCode + " Error: " + (qs == null ? target : target + "?" + qs), e);

代码示例来源:origin: JpressProjects/jpress

@Override
  public void send(Email email) {
    if (enable == false) {
      //do nothing
      return;
    }

    Message message = createMessage();
    try {
      message.setSubject(email.getSubject());
      message.setContent(email.getContent(), "text/html;charset=utf-8");

      message.setRecipients(Message.RecipientType.TO, toAddress(email.getTo()));
      message.setRecipients(Message.RecipientType.CC, toAddress(email.getCc()));

      Transport.send(message);
    } catch (MessagingException e) {
      logger.error("SimpleEmailSender send error", e);
    }

  }
}

代码示例来源:origin: JpressProjects/jpress

/**
 * 同步本地文件到阿里云OSS
 *
 * @param path
 * @param file
 * @return
 */
public static boolean uploadsync(String path, File file) {
  boolean enable = JPressOptions.getAsBool(KEY_ENABLE);
  if (enable == false || StrUtils.isBlank(path)) {
    return false;
  }
  path = removeFileSeparator(path);
  path = path.replace('\\', '/');
  String ossBucketName = JPressOptions.get(KEY_BUCKETNAME);
  OSSClient ossClient = newOSSClient();
  try {
    ossClient.putObject(ossBucketName, path, file);
    boolean success = ossClient.doesObjectExist(ossBucketName, path);
    if (!success) {
      LogKit.error("aliyun oss upload error! path:" + path + "\nfile:" + file);
    }
    return success;
  } catch (Throwable e) {
    log.error("aliyun oss upload error!!!", e);
    return false;
  } finally {
    ossClient.shutdown();
  }
}

代码示例来源:origin: jfinal/jfinal

if (log.isErrorEnabled()) {
  String qs = request.getQueryString();
  log.error(qs == null ? target : target + "?" + qs, e);
if (log.isErrorEnabled()) {
  String qs = request.getQueryString();
  log.error(qs == null ? target : target + "?" + qs, e);

代码示例来源:origin: yangfuhai/jboot

@Override
public void publish(Object message, String toChannel) {
  Producer producer = getProducer(toChannel);
  Message msg = new Message();
  msg.setTopic(toChannel);
  msg.setBody(Jboot.me().getSerializer().serialize(message));
  try {
    producer.publish(msg);
  } catch (Exception e) {
    LOG.error(e.toString(), e);
  }
}

相关文章