Class Logger

java.lang.Object
org.nineml.logging.Logger
Direct Known Subclasses:
CachingLogger, DefaultLogger, SystemLogger

public abstract class Logger extends Object
The abstract class that all concrete loggers must extend.
  • Field Details

    • logcategory

      public static final String logcategory
      The logging catagory for logger messages.
      See Also:
    • defaultLogLevelProperty

      public static final String defaultLogLevelProperty
      The system property for setting the default log level.
      See Also:
    • logLevelsProperty

      public static final String logLevelsProperty
      The system property for setting the category:loglevel mappings.
      See Also:
    • SILENT

      public static final int SILENT
      The log level to indicate no logging, not even errors.
      See Also:
    • ERROR

      public static final int ERROR
      The log level for error messages.
      See Also:
    • WARNING

      public static final int WARNING
      The log level for warning messages.
      See Also:
    • INFO

      public static final int INFO
      The log level for informational messages.
      See Also:
    • DEBUG

      public static final int DEBUG
      The log level for debug messages.
      See Also:
    • TRACE

      public static final int TRACE
      The log level for trace messages.
      See Also:
  • Constructor Details

    • Logger

      public Logger()
  • Method Details

    • readSystemProperties

      public void readSystemProperties()
      Set the log levels by reading system properties.

      The properties are:

      • defaultLogLevelProperty

        Must be an integer specifying the initial default log level or one of the strings "silent", "error", "warning", "info", "debug", or "trace". Absent this property, the default level is 5, or "error".

      • logLevelsProperty

        This property specifies a mapping between log categories and the log level for each category. The format of the property is a list of comma or space separated values of the form "category:level". The category "*" sets the default log level.

    • getDefaultLogLevel

      public int getDefaultLogLevel()
      Get the default log level
      Returns:
      the default log level
    • setDefaultLogLevel

      public void setDefaultLogLevel(int level)
      Set the default log level.

      If the level is less than zero, it will be set to 0 (silent).

      Parameters:
      level - the level
    • setDefaultLogLevel

      public void setDefaultLogLevel(String level)
      Set the default log level.

      The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.

      Parameters:
      level - the level.
      Throws:
      NullPointerException - if the level is null.
    • getLogCategories

      public Set<String> getLogCategories()
      Get all of the configured log level categories
      Returns:
      the set of categories
    • getLogLevel

      public int getLogLevel(String category)
      Get the log level for a particular category.

      Category names are not case sensitive.

      Parameters:
      category - the category
      Returns:
      the level
      Throws:
      NullPointerException - if the category is null
    • setLogLevel

      public void setLogLevel(String category, int level)
      Set the log level for a particular category.
      Parameters:
      category - the category
      level - the level
      Throws:
      NullPointerException - if the category is null.
    • setLogLevel

      public void setLogLevel(String category, String level)
      Set the log level for a particular category.

      The level must be "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used.

      Parameters:
      category - the category.
      level - the level.
      Throws:
      NullPointerException - if the category or level is null.
    • setLogLevels

      public void setLogLevels(String config)
      Set the log levels for a set of categories.

      The config specifies a mapping between log categories and the log level for each category. The format of the string is a list of comma or space separated values of the form "category:level".

      The level must be an integer or one of "silent", "error", "warning", "info", "debug", or "trace". If an invalid value is specified, "error" is used. The category "*" sets the default log level.

      Parameters:
      config - the category.
    • clearLogLevels

      public void clearLogLevels()
      Clear the log levels.

      This method removes all configured log levels. All subsequent logging (until more levels are set) will be based entirely on the default log level.

    • error

      public abstract void error(String category, String format, Object... params)
      Issue an error message.
      Parameters:
      category - the message category
      format - the format string
      params - message parameters
    • warn

      public abstract void warn(String category, String format, Object... params)
      Issue a warning message.
      Parameters:
      category - the message category
      format - the format string
      params - message parameters
    • info

      public abstract void info(String category, String format, Object... params)
      Issue an informational message.
      Parameters:
      category - the message category
      format - the format string
      params - message parameters
    • debug

      public abstract void debug(String category, String format, Object... params)
      Issue a debug message.
      Parameters:
      category - the message category
      format - the format string
      params - message parameters
    • trace

      public abstract void trace(String category, String format, Object... params)
      Issue a trace message.
      Parameters:
      category - the message category
      format - the format string
      params - message parameters