Package com.sodius.mdw.core.util.log
Class FileLogger
- java.lang.Object
-
- com.sodius.mdw.core.util.log.AbstractLogger
-
- com.sodius.mdw.core.util.log.FileLogger
-
- All Implemented Interfaces:
Logger
public class FileLogger extends AbstractLogger
Outputs log information into a file.Clients may instantiate or subclass this class.
-
-
Constructor Summary
Constructors Constructor Description FileLogger(File file)Constructs a logger which outputs log information into the specified file.FileLogger(File file, boolean append)Constructs a logger which outputs log information into the specified file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidlog(Level level, Object message, Throwable error)Appends the specified message and error to the underlying file.
-
-
-
Constructor Detail
-
FileLogger
public FileLogger(File file) throws FileNotFoundException
Constructs a logger which outputs log information into the specified file.If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a
FileNotFoundExceptionis thrown.- Parameters:
file- the file where to log information.- Throws:
FileNotFoundException- if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
-
FileLogger
public FileLogger(File file, boolean append) throws FileNotFoundException
Constructs a logger which outputs log information into the specified file.If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a
FileNotFoundExceptionis thrown.- Parameters:
file- the file where to log information.append- iftrue, then information will be written to the end of the file rather than the beginning.- Throws:
FileNotFoundException- if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.
-
-
Method Detail
-
log
protected void log(Level level, Object message, Throwable error)
Appends the specified message and error to the underlying file. This default implementation always output information the same way, whatever the log level is.- Specified by:
login classAbstractLogger- Parameters:
level- the log level (not considered by the implementation).message- the information to log (usually aString), maybenull.error- an exception to log, maybenull.
-
-