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

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

本文整理了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

  1. private static void logInLogger(boolean error, String message, Throwable exception) {
  2. boolean canUseRealLogger;
  3. synchronized (Logger.class) {
  4. canUseRealLogger = loggerFactory != null && !(loggerFactory instanceof _NullLoggerFactory);
  5. }
  6. if (canUseRealLogger) {
  7. try {
  8. final Logger logger = Logger.getLogger("freemarker.logger");
  9. if (error) {
  10. logger.error(message);
  11. } else {
  12. logger.warn(message);
  13. }
  14. } catch (Throwable e) {
  15. canUseRealLogger = false;
  16. }
  17. }
  18. if (!canUseRealLogger) {
  19. System.err.println((error ? "ERROR" : "WARN") + " "
  20. + LoggerFactory.class.getName() + ": " + message);
  21. if (exception != null) {
  22. System.err.println("\tException: " + tryToString(exception));
  23. while (exception.getCause() != null) {
  24. exception = exception.getCause();
  25. System.err.println("\tCaused by: " + tryToString(exception));
  26. }
  27. }
  28. }
  29. }

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

  1. private static void logInLogger(boolean error, String message, Throwable exception) {
  2. boolean canUseRealLogger;
  3. synchronized (Logger.class) {
  4. canUseRealLogger = loggerFactory != null && !(loggerFactory instanceof _NullLoggerFactory);
  5. }
  6. if (canUseRealLogger) {
  7. try {
  8. final Logger logger = Logger.getLogger("freemarker.logger");
  9. if (error) {
  10. logger.error(message);
  11. } else {
  12. logger.warn(message);
  13. }
  14. } catch (Throwable e) {
  15. canUseRealLogger = false;
  16. }
  17. }
  18. if (!canUseRealLogger) {
  19. System.err.println((error ? "ERROR" : "WARN") + " "
  20. + LoggerFactory.class.getName() + ": " + message);
  21. if (exception != null) {
  22. System.err.println("\tException: " + tryToString(exception));
  23. while (exception.getCause() != null) {
  24. exception = exception.getCause();
  25. System.err.println("\tCaused by: " + tryToString(exception));
  26. }
  27. }
  28. }
  29. }

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

  1. private static void logInLogger(boolean error, String message, Throwable exception) {
  2. boolean canUseRealLogger;
  3. synchronized (Logger.class) {
  4. canUseRealLogger = loggerFactory != null && !(loggerFactory instanceof _NullLoggerFactory);
  5. }
  6. if (canUseRealLogger) {
  7. try {
  8. final Logger logger = Logger.getLogger("freemarker.logger");
  9. if (error) {
  10. logger.error(message);
  11. } else {
  12. logger.warn(message);
  13. }
  14. } catch (Throwable e) {
  15. canUseRealLogger = false;
  16. }
  17. }
  18. if (!canUseRealLogger) {
  19. System.err.println((error ? "ERROR" : "WARN") + " "
  20. + LoggerFactory.class.getName() + ": " + message);
  21. if (exception != null) {
  22. System.err.println("\tException: " + tryToString(exception));
  23. while (exception.getCause() != null) {
  24. exception = exception.getCause();
  25. System.err.println("\tCaused by: " + tryToString(exception));
  26. }
  27. }
  28. }
  29. }

相关文章