Class LogManager

java.lang.Object
eu.cloudnetservice.common.log.LogManager

public final class LogManager extends Object
The log manager provides static access to underlying api to shortcut logger creation methods for easier accessibility.
Since:
4.0
  • Field Details

    • LOGGER_FACTORY

      private static final LoggerFactory LOGGER_FACTORY
  • Constructor Details

    • LogManager

      private LogManager()
  • Method Details

    • rootLogger

      @NonNull public static @NonNull Logger rootLogger()
      Gets the root logger for the system from the currently used logger factory.
      Returns:
      the root logger.
    • logger

      @NonNull public static @NonNull Logger logger(@NonNull @NonNull Class<?> caller)
      Gets a logger from the current logger factory which has the name of the given class.
      Parameters:
      caller - the class to get the logger for.
      Returns:
      a logger with the name of the given class.
      Throws:
      NullPointerException - if the given class is null.
    • logger

      @NonNull public static @NonNull Logger logger(@NonNull @NonNull String name)
      Gets a logger from the current logger factory which has the given name.
      Parameters:
      name - the name of the logger to get.
      Returns:
      a logger with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • loggerFactory

      @NonNull public static @NonNull LoggerFactory loggerFactory()
      Gets the current logger factory which the system uses. The factory is statically initialized with the class and will never change once initialized.
      Returns:
      the current selected logger factory.
    • loadLoggerFactory

      @NonNull private static @NonNull LoggerFactory loadLoggerFactory()
      Selects the logger factory use. This method tries to load all providers for the logger factory class and uses the first one which is available (if any) and uses it as the factory for loggers. If no logger factory service is available on the class path this method falls back to the fallback logger factory which creates loggers wrapping java.util.logging loggers.
      Returns:
      the logger factory to use in the runtime.
      Throws:
      ServiceConfigurationError - if something went wrong during the service loading or instantiation.