Class FileLogger

java.lang.Object
net.ssehub.easy.basics.logger.AbstractJavaLogger
net.ssehub.easy.basics.logger.FileLogger
All Implemented Interfaces:
ILogger

public class FileLogger extends AbstractJavaLogger
Simple logger for logging into a specified file.
Author:
El-Sharkawy
  • Field Details

    • instance

      private static FileLogger instance
    • fileHandler

      private Handler fileHandler
    • logger

      private Logger logger
  • Constructor Details

    • FileLogger

      private FileLogger(String path, boolean append) throws SecurityException, IOException
      Creates an ILogger for logging into a specified file.
      Parameters:
      path - The path of the file where the log file shall be written.
      append - If true log data will be appended to existing files, otherwise existing files will be overwritten
      Throws:
      IOException - if there are IO problems opening the files.
      SecurityException - if a security manager exists and if the caller does not have LoggingPermission("control").
      IllegalArgumentException - if pattern is an empty string
  • Method Details

    • getInstance

      public static FileLogger getInstance(String path, boolean append)
      Returns the singleton instance of this ILogger implementation.
      Parameters:
      path - The path of the file where the log file shall be written.
      append - If true log data will be appended to existing files, otherwise existing files will be overwritten
      Returns:
      The first successfully created logger, or null if no logger could be created, e.g. if no valid path was specified.
    • info

      public void info(String msg, Class<?> clazz, String bundleName)
      Description copied from interface: ILogger
      Log an INFO message. If the logger is currently enabled for the INFO message level then the given message is forwarded to all the registered output Handler objects.
      Parameters:
      msg - The string message (or a key in the message catalog)
      clazz - The class where the message was created
      bundleName - Name of the bundle where the message was created
    • error

      public void error(String msg, Class<?> clazz, String bundleName)
      Description copied from interface: ILogger
      Log an ERROR message. If the logger is currently enabled for the ERROR message level then the given message is forwarded to all the registered output Handler objects.
      Parameters:
      msg - The string message (or a key in the message catalog)
      clazz - The class where the message was created
      bundleName - Name of the bundle where the message was created
    • warn

      public void warn(String msg, Class<?> clazz, String bundleName)
      Description copied from interface: ILogger
      Log a WARN message. If the logger is currently enabled for the WARN message level then the given message is forwarded to all the registered output Handler objects.
      Parameters:
      msg - The string message (or a key in the message catalog)
      clazz - The class where the message was created
      bundleName - Name of the bundle where the message was created
    • debug

      public void debug(String msg, Class<?> clazz, String bundleName)
      Description copied from interface: ILogger
      Log a DEBUG message. If the logger is currently enabled for the DEBUG message level then the given message is forwarded to all the registered output Handler objects.
      Parameters:
      msg - The string message (or a key in the message catalog)
      clazz - The class where the message was created
      bundleName - Name of the bundle where the message was created
    • exception

      public void exception(String msg, Class<?> clazz, String bundleName)
      Description copied from interface: ILogger
      Log an EXCEPTION message. If the logger is currently enabled for the EXCEPTION message level then the given message is forwarded to all the registered output Handler objects.
      Parameters:
      msg - The string message (or a key in the message catalog)
      clazz - The class where the message was created
      bundleName - Name of the bundle where the message was created