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

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

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

Logger.tryToString介绍

[英]Don't use freemarker.template.utility.StringUtil#tryToString(Object) here, as it might depends on the logger, hence interfering with the initialization.
[中]不要使用自由标记。样板公用事业StringUtil#tryToString(对象),因为它可能取决于记录器,因此会干扰初始化。

代码示例

代码示例来源: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-gae

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.apache.servicemix.bundles/org.apache.servicemix.bundles.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));
      }
    }
  }
}

相关文章