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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.ssehub.easy.basics.logger.AbstractJavaLogger
AbstractJavaLogger.ConsoleHandler
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.logging.HandlerfileHandlerprivate static FileLoggerinstanceprivate java.util.logging.Loggerlogger-
Fields inherited from class net.ssehub.easy.basics.logger.AbstractJavaLogger
DEBUG_LEVEL, DEFAULT_LEVEL, EXCEPTION_LEVEL, LOG_FORMATTER
-
-
Constructor Summary
Constructors Modifier Constructor Description privateFileLogger(java.lang.String path, boolean append)Creates anILoggerfor logging into a specified file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Log an DEBUG message.voiderror(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Log an ERROR message.voidexception(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Log an EXCEPTION message.static FileLoggergetInstance(java.lang.String path, boolean append)Returns the singleton instance of thisILoggerimplementation.voidinfo(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Log an INFO message.voidwarn(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Log an WARN message.-
Methods inherited from class net.ssehub.easy.basics.logger.AbstractJavaLogger
createLogger
-
-
-
-
Field Detail
-
instance
private static FileLogger instance
-
fileHandler
private java.util.logging.Handler fileHandler
-
logger
private java.util.logging.Logger logger
-
-
Constructor Detail
-
FileLogger
private FileLogger(java.lang.String path, boolean append) throws java.lang.SecurityException, java.io.IOExceptionCreates anILoggerfor 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:
java.io.IOException- if there are IO problems opening the files.java.lang.SecurityException- if a security manager exists and if the caller does not have LoggingPermission("control").java.lang.IllegalArgumentException- if pattern is an empty string
-
-
Method Detail
-
getInstance
public static FileLogger getInstance(java.lang.String path, boolean append)
Returns the singleton instance of thisILoggerimplementation.- 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(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Description copied from interface:ILoggerLog 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 createdbundleName- Name of the bundle where the message was created
-
error
public void error(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Description copied from interface:ILoggerLog 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 createdbundleName- Name of the bundle where the message was created
-
warn
public void warn(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Description copied from interface:ILoggerLog an 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 createdbundleName- Name of the bundle where the message was created
-
debug
public void debug(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Description copied from interface:ILoggerLog an 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 createdbundleName- Name of the bundle where the message was created
-
exception
public void exception(java.lang.String msg, java.lang.Class<?> clazz, java.lang.String bundleName)Description copied from interface:ILoggerLog 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 createdbundleName- Name of the bundle where the message was created
-
-