Package gov.usgs.util.logging
Class SimpleLogFileHandler
java.lang.Object
java.util.logging.Handler
gov.usgs.util.logging.SimpleLogFileHandler
A java.util.logging style Handler that does daily log rotation by default.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleLogFileHandler
(File logDirectory) Create a default SimpleLogHandler.SimpleLogFileHandler
(File logDirectory, SimpleDateFormat filenameFormat) Create a SimpleLogHandler with a custom filename format. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the current log file.void
flush()
Attempts to flush any buffered content.protected OutputStream
getOutputStream
(Date date) Retrieve the outputstream for the current log file.static void
Testing for handlervoid
Add a LogRecord to the log file.Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
DEFAULT_FILENAME_FORMAT
Default format used.- See Also:
-
-
Constructor Details
-
SimpleLogFileHandler
Create a default SimpleLogHandler. Uses the system locale to roll log files once a day, and default filename format "log_YYYYMMDD.log".- Parameters:
logDirectory
- the directory to write log files.
-
SimpleLogFileHandler
Create a SimpleLogHandler with a custom filename format.- Parameters:
logDirectory
- the directory to write log files.filenameFormat
- the format for log files. Files are opened as soon as the format output changes for a given log's message.
-
-
Method Details
-
close
Closes the current log file.- Specified by:
close
in classHandler
- Throws:
SecurityException
-
flush
public void flush()Attempts to flush any buffered content. If exceptions occur, the stream is closed. -
getOutputStream
Retrieve the outputstream for the current log file.- Parameters:
date
- the date of the message about to be logged.- Returns:
- and OutputStream where the log message may be written.
- Throws:
IOException
- if errors occur.
-
publish
Add a LogRecord to the log file. -
main
Testing for handler- Parameters:
args
- CLI args- Throws:
Exception
- if error occurs
-