Class Log


  • public final class Log
    extends java.lang.Object
    A collection of methods to make logging things easier.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getLogFileName()
      Compute the filename of the log file
      static java.lang.String getLogFilePath()
      Compute the full path of the log file
      static java.lang.String getLogLocation()
      Returns the path to the log file.
      static void log​(java.lang.String s)
      Logs what otherwise would go to System.out
      static void log​(java.lang.Throwable throwable)
      Logs an Exception or Error.
      static void logDebug​(java.util.logging.Logger logger, java.lang.String message, java.lang.Object... parameters)
      Writes debug message to log (without localization)
      static void logErrorRB​(java.lang.String key, java.lang.Object... parameters)
      Writes an error message to the log (to be retrieved from the resource bundle)
      static void logErrorRB​(java.lang.Throwable ex, java.lang.String key, java.lang.Object... parameters)
      Writes an error message to the log (to be retrieved from the resource bundle)
      static void logInfoRB​(java.lang.String key, java.lang.Object... parameters)
      Writes an info message to the log (to be retrieved from the resource bundle)
      static void logRB​(java.lang.String key, java.lang.Object... parameters)
      Logs a message, retrieved from the resource bundle.
      static void logWarningRB​(java.lang.String key, java.lang.Object... parameters)
      Writes a warning message to the log (to be retrieved from the resource bundle)
      static void setLevel​(java.util.logging.Level level)
      Set the level for the global logger.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getLogLocation

        public static java.lang.String getLogLocation()
        Returns the path to the log file.
      • getLogFileName

        public static java.lang.String getLogFileName()
        Compute the filename of the log file
        Returns:
        the filename of the log, or an empty string
      • getLogFilePath

        public static java.lang.String getLogFilePath()
        Compute the full path of the log file
        Returns:
        the full path of the log file
      • setLevel

        public static void setLevel​(java.util.logging.Level level)
        Set the level for the global logger. This is normally determined by the logger.properties file; use this method to override for special use cases.
        Parameters:
        level - The new level
      • log

        public static void log​(java.lang.String s)
        Logs what otherwise would go to System.out
      • logRB

        public static void logRB​(java.lang.String key,
                                 java.lang.Object... parameters)
        Logs a message, retrieved from the resource bundle.
        Parameters:
        key - The key of the message in the resource bundle.
        parameters - Parameters for the message. These are inserted by using StaticUtils.format.
      • log

        public static void log​(java.lang.Throwable throwable)
        Logs an Exception or Error. To the log are written: - The class name of the Exception or Error - The message, if any - The stack trace
        Parameters:
        throwable - The exception or error to log
      • logWarningRB

        public static void logWarningRB​(java.lang.String key,
                                        java.lang.Object... parameters)
        Writes a warning message to the log (to be retrieved from the resource bundle)

        While the warning message can be localized, the warning key is also logged, so developers can determine what warning was given by looking at the error key, instead of trying to interpret localized messages.

        Parameters:
        key - The key of the error message in the resource bundle
        parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
      • logInfoRB

        public static void logInfoRB​(java.lang.String key,
                                     java.lang.Object... parameters)
        Writes an info message to the log (to be retrieved from the resource bundle)

        While the info message can be localized, the info key is also logged, so developers can determine what info was given by looking at the error key, instead of trying to interpret localized messages.

        Parameters:
        key - The key of the error message in the resource bundle
        parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
      • logErrorRB

        public static void logErrorRB​(java.lang.String key,
                                      java.lang.Object... parameters)
        Writes an error message to the log (to be retrieved from the resource bundle)

        While the error message can be localized, the error key is also logged, so developers can determine what error was given by looking at the error key, instead of trying to interpret localized messages.

        Parameters:
        key - The key of the error message in the resource bundle
        parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
      • logErrorRB

        public static void logErrorRB​(java.lang.Throwable ex,
                                      java.lang.String key,
                                      java.lang.Object... parameters)
        Writes an error message to the log (to be retrieved from the resource bundle)

        While the error message can be localized, the error key is also logged, so developers can determine what error was given by looking at the error key, instead of trying to interpret localized messages.

        Parameters:
        ex - The error that was thrown
        key - The key of the error message in the resource bundle
        parameters - Parameters for the error message. These are inserted by using StaticUtils.format.
      • logDebug

        public static void logDebug​(java.util.logging.Logger logger,
                                    java.lang.String message,
                                    java.lang.Object... parameters)
        Writes debug message to log (without localization)
        Parameters:
        message - message text
        parameters - Parameters for the error message. These are inserted by using StaticUtils.format.