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

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

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

Logger.getLogger介绍

[英]Returns a logger for the specified category.
[中]返回指定类别的记录器。

代码示例

代码示例来源: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));
      }
    }
  }
}

相关文章