Class RotatingFileAppender
- java.lang.Object
-
- org.glassfish.grizzly.http.server.accesslog.RotatingFileAppender
-
- All Implemented Interfaces:
Closeable,AutoCloseable,AccessLogAppender
public class RotatingFileAppender extends Object implements AccessLogAppender
- Author:
- Pier Fumagalli, USRZ.com
-
-
Constructor Summary
Constructors Constructor Description RotatingFileAppender(File directory, String filePattern)Create aRotatingFileAppenderwriting access log files in the specified directory and using the specifiedSimpleDateFormatpattern to generate file names.RotatingFileAppender(File directory, String fileName, String archivePattern)Create aRotatingFileAppenderwriting access log files in the specified directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(String accessLogEntry)Append the specified access log entry.voidclose()Close any underlying resource owned by this appender.
-
-
-
Constructor Detail
-
RotatingFileAppender
public RotatingFileAppender(File directory, String filePattern) throws IOException
Create aRotatingFileAppenderwriting access log files in the specified directory and using the specifiedSimpleDateFormatpattern to generate file names.For example when the specified pattern is
'access-'yyyyMMDDhh'.log'(note the quotes), access log files will be rotated on a hourly basis, and the output will be written to files likeaccess-2013120422.log,access-2013120423.log, ... and so on.- Parameters:
directory- The directory where access log files will be written to.filePattern- A properly escapedSimpleDateFormatpattern for the access log files.- Throws:
IOException- If an I/O error occurred accessing the filesystem.
-
RotatingFileAppender
public RotatingFileAppender(File directory, String fileName, String archivePattern) throws IOException
Create aRotatingFileAppenderwriting access log files in the specified directory.When using this constructor the current log file (the one being written to) will always be the one identified by the
fileNameparameter, and then archival of files will be delegated to the archive pattern.For example when
fileNameiscurrent.logandarchivePatternis'archive-'yyyyMMDD'.log'(note the quotes), access logs will be written to thecurrent.logfile and this file will be rotated on a daily basis to files likearchive-20131204.log,archive-20131205.log, ... and so on.- Parameters:
directory- The directory where access log files will be written to.fileName- A file name where log entries will be written to.archivePattern- A properly escapedSimpleDateFormatpattern for the access log archive files.- Throws:
IOException- If an I/O error occurred accessing the filesystem.
-
-
Method Detail
-
append
public void append(String accessLogEntry) throws IOException
Description copied from interface:AccessLogAppenderAppend the specified access log entry.- Specified by:
appendin interfaceAccessLogAppender- Parameters:
accessLogEntry- TheStringvalue of the data to be append in the access log.- Throws:
IOException- If an I/O error occurred appending to the log.
-
close
public void close() throws IOExceptionDescription copied from interface:AccessLogAppenderClose any underlying resource owned by this appender.- Specified by:
closein interfaceAccessLogAppender- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-