freemarker.log.Logger.error()方法的使用及代码示例

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

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

Logger.error介绍

[英]Logs an error message.
[中]记录一条错误消息。

代码示例

代码示例来源:origin: org.freemarker/freemarker

public void stop() {
    this.stop = true;
    if (serverSocket != null) {
      try {
        serverSocket.close();
      } catch (IOException e) {
        LOG.error("Unable to close server socket.", e);
      }
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker

public void report(TemplateException te, Environment env) {
  String message = "Error executing FreeMarker template part in the #attempt block";
  if (!logAsWarn) {
    LOG.error(message, te);
  } else {
    LOG.warn(message, te);
  }
}

代码示例来源:origin: org.freemarker/freemarker

private ServletException newServletExceptionWithFreeMarkerLogging(String message, Throwable cause) throws ServletException {
  if (cause instanceof TemplateException) {
    // For backward compatibility, we log into the same category as Environment did when
    // log_template_exceptions was true.
    LOG_RT.error(message, cause);
  } else {
    LOG.error(message, cause);
  }
  ServletException e = new ServletException(message, cause);
  try {
    // Prior to Servlet 2.5, the cause exception wasn't set by the above constructor.
    // If we are on 2.5+ then this will throw an exception as the cause was already set.
    e.initCause(cause);
  } catch (Exception ex) {
    // Ignored; see above
  }
  throw e;
}

代码示例来源:origin: org.freemarker/freemarker

/**
 * Gets a servlet context resource as a {@link JarFile} if possible, return {@code null} otherwise.
 * For BC only, we try to get over errors during URL/JarFile construction, so then the caller can fall back to the
 * legacy ZipInputStream-based approach.
 */
private JarFile servletContextResourceToFileOrNull(final String jarResourcePath) throws MalformedURLException,
    IOException {
  URL jarResourceUrl = servletContext.getResource(jarResourcePath);
  if (jarResourceUrl == null) {
    LOG.error("ServletContext resource URL was null (missing resource?): " + jarResourcePath);
    return null;
  }
  File jarResourceAsFile = urlToFileOrNull(jarResourceUrl);
  if (jarResourceAsFile == null) {
    // Expected - it's just not File
    return null;
  }
  if (!jarResourceAsFile.isFile()) {
    LOG.error("Jar file doesn't exist - falling back to stream mode: " + jarResourceAsFile);
    return null;
  }
  return new JarFile(jarResourceAsFile);
}

代码示例来源:origin: org.freemarker/freemarker

private void startInternal() {
  try {
    serverSocket = new ServerSocket(port);
    while (!stop) {
      Socket s = serverSocket.accept();
      new Thread(new DebuggerAuthProtocol(s)).start();
    }
  } catch (IOException e) {
    LOG.error("Debugger server shut down.", e);
  }
}

代码示例来源:origin: org.freemarker/freemarker

XPathSupport getXPathSupport() {
  if (jaxenXPathSupport != null) {
    return jaxenXPathSupport;
  }
  XPathSupport xps = null;
  Document doc = node.getOwnerDocument();
  if (doc == null) {
    doc = (Document) node;
  }
  synchronized (doc) {
    WeakReference ref = (WeakReference) xpathSupportMap.get(doc);
    if (ref != null) {
      xps = (XPathSupport) ref.get();
    }
    if (xps == null) {
      try {
        xps = (XPathSupport) xpathSupportClass.newInstance();
        xpathSupportMap.put(doc, new WeakReference(xps));
      } catch (Exception e) {
        LOG.error("Error instantiating xpathSupport class", e);
      }                
    }
  }
  return xps;
}

代码示例来源:origin: org.freemarker/freemarker

private static URL tryCreateServletContextJarEntryUrl(
    ServletContext servletContext, final String servletContextJarFilePath, final String entryPath) {
  try {
    final URL jarFileUrl = servletContext.getResource(servletContextJarFilePath);
    if (jarFileUrl == null) {
      throw new IOException("Servlet context resource not found: " + servletContextJarFilePath);
    }
    return new URL(
        "jar:"
        + jarFileUrl.toURI()
        + JAR_URL_ENTRY_PATH_START
        + URLEncoder.encode(
            entryPath.startsWith("/") ? entryPath.substring(1) : entryPath,
            PLATFORM_FILE_ENCODING));
  } catch (Exception e) {
    LOG.error("Couldn't get URL for serlvetContext resource "
          + StringUtil.jQuoteNoXSS(servletContextJarFilePath)
          + " / jar entry " + StringUtil.jQuoteNoXSS(entryPath),
        e);
    return null;
  }
}

代码示例来源:origin: org.freemarker/freemarker

private static ExpressionFactory tryExpressionFactoryImplementation(String packagePrefix) {
  String className = packagePrefix + ".el.ExpressionFactoryImpl";
  try {
    Class cl = ClassUtil.forName(className);
    if (ExpressionFactory.class.isAssignableFrom(cl)) {
      LOG.info("Using " + className + " as implementation of " + 
          ExpressionFactory.class.getName());
      return (ExpressionFactory) cl.newInstance();
    }
    LOG.warn("Class " + className + " does not implement " + 
        ExpressionFactory.class.getName());
  } catch (ClassNotFoundException e) {
  } catch (Exception e) {
    LOG.error("Failed to instantiate " + className, e);
  }
  return null;
}

代码示例来源:origin: org.freemarker/freemarker

LOG.error("Failed to print FTL stack trace", e);

代码示例来源:origin: org.freemarker/freemarker

private static void logInLogger(boolean error, String message, Throwable exception) {
  boolean canUseRealLogger;
  synchronized (Logger.class) {
    canUseRealLogger = loggerFactory != null && !(loggerFactory instanceof _NullLoggerFactory);
  }
  if (canUseRealLogger) {
    try {
      final Logger logger = Logger.getLogger("freemarker.logger");
      if (error) {
        logger.error(message);
      } else {
        logger.warn(message);
      }
    } catch (Throwable e) {
      canUseRealLogger = false;
    }
  }
  if (!canUseRealLogger) {
    System.err.println((error ? "ERROR" : "WARN") + " "
        + LoggerFactory.class.getName() + ": " + message);
    if (exception != null) {
      System.err.println("\tException: " + tryToString(exception));
      while (exception.getCause() != null) {
        exception = exception.getCause();
        System.err.println("\tCaused by: " + tryToString(exception));
      }
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker

/**
 * Use this overload only if you already have the {@link InputStream} for some reason, otherwise use
 * {@link #addTldLocationFromTld(TldLocation)}. 
 * 
 * @param reusedIn
 *            The stream that we already had (so we don't have to open a new one from the {@code tldLocation}).
 */
private void addTldLocationFromTld(InputStream reusedIn, TldLocation tldLocation) throws SAXException,
    IOException {
  String taglibUri;
  try {
    taglibUri = getTaglibUriFromTld(reusedIn, tldLocation.getXmlSystemId());
  } catch (SAXException e) {
    LOG.error("Error while parsing TLD; skipping: " + tldLocation, e);
    synchronized (failedTldLocations) {
      failedTldLocations.add(tldLocation.toString());
    }
    taglibUri = null;
  }
  if (taglibUri != null) {
      addTldLocation(tldLocation, taglibUri);
  }
}

代码示例来源:origin: org.freemarker/freemarker

LOG.error("Failed to open InputStream for URL (will try fallback stream): " + entryUrl);

代码示例来源:origin: org.freemarker/freemarker

LOG.error("Error when searching blamer for better error message.", e);

代码示例来源:origin: org.freemarker/freemarker

jettyTaglibJarPatterns = attrVal != null ? InitParamParser.parseCommaSeparatedPatterns(attrVal) : null;
} catch (Exception e) {
  LOG.error("Failed to parse application context attribute \""
      + ATTR_JETTY_CP_TAGLIB_JAR_PATTERNS + "\" - it will be ignored", e);

代码示例来源:origin: org.freemarker/freemarker

LOG.error("Error executing FreeMarker template", templateException);

代码示例来源:origin: org.freemarker/freemarker-gae

public void stop() {
    this.stop = true;
    if (serverSocket != null) {
      try {
        serverSocket.close();
      } catch (IOException e) {
        LOG.error("Unable to close server socket.", e);
      }
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

public void stop() {
    this.stop = true;
    if (serverSocket != null) {
      try {
        serverSocket.close();
      } catch (IOException e) {
        LOG.error("Unable to close server socket.", e);
      }
    }
  }
}

代码示例来源:origin: org.freemarker/freemarker-gae

public void report(TemplateException te, Environment env) {
  String message = "Error executing FreeMarker template part in the #attempt block";
  if (!logAsWarn) {
    LOG.error(message, te);
  } else {
    LOG.warn(message, te);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

public void report(TemplateException te, Environment env) {
  String message = "Error executing FreeMarker template part in the #attempt block";
  if (!logAsWarn) {
    LOG.error(message, te);
  } else {
    LOG.warn(message, te);
  }
}

代码示例来源:origin: com.haoxuer.discover/discover-common-freemarker

@SuppressWarnings("unchecked")
Object getPrincipalFromClassName(Map params) {
  String type = getType(params);
  try {
    Class cls = Class.forName(type);
    
    return getSubject().getPrincipals().oneByType(cls);
  } catch (ClassNotFoundException ex) {
    log.error("Unable to find class for name ["+type+"]", ex);
  }
  return null;
}

相关文章