Top Description Fields Constructors Methods
org.glassfish.grizzly.http.server.accesslog

public Class RotatingFileAppender

extends Object
implements AccessLogAppender
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.http.server.accesslog.AccessLogAppender, java.io.Closeable, java.lang.AutoCloseable
Static Imports
java.util.logging.Level.WARNING

An appender writing log entries to Files, and rotating/archiving them when necessary.
Authors
Pier Fumagalli, USRZ.com

Field Summary

Modifier and TypeField and Description
private FileAppender
private final DateTimeFormatter
private boolean
private File
private File
private final File
private final DateTimeFormatter
private static final Logger

Constructor Summary

AccessConstructor and Description
public
RotatingFileAppender(File
The directory where access log files will be written to.
directory
,
String
A properly escaped DateTimeFormatter pattern for the access log files.
filePattern
)

Create a RotatingFileAppender writing access log files in the specified directory and using the specified DateTimeFormatter pattern to generate file names.

public
RotatingFileAppender(File
The directory where access log files will be written to.
directory
,
String
A file name where log entries will be written to.
fileName
,
String
A properly escaped DateTimeFormatter pattern for the access log archive files.
archivePattern
)

Create a RotatingFileAppender writing access log files in the specified directory.

private
RotatingFileAppender(String filePattern, String archivePattern, File directory)

Method Summary

Modifier and TypeMethod and Description
public void
append(String accessLogEntry)

Implements org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.append.

Append the specified access log entry.

public void
close()

Implements org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.close.

Close any underlying resource owned by this appender.

private static String
escape(String fileName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

appenderback to summary
private FileAppender appender
archiveFormatback to summary
private final DateTimeFormatter archiveFormat
closedback to summary
private boolean closed
currentArchiveback to summary
private File currentArchive
currentFileback to summary
private File currentFile
directoryback to summary
private final File directory
fileFormatback to summary
private final DateTimeFormatter fileFormat
LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

RotatingFileAppenderback to summary
public RotatingFileAppender(File directory, String filePattern) throws IOException

Create a RotatingFileAppender writing access log files in the specified directory and using the specified DateTimeFormatter pattern 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 like access-2013120422.log, access-2013120423.log, ... and so on.

Parameters
directory:File

The directory where access log files will be written to.

filePattern:String

A properly escaped DateTimeFormatter pattern for the access log files.

Exceptions
IOException:
If an I/O error occurred accessing the filesystem.
RotatingFileAppenderback to summary
public RotatingFileAppender(File directory, String fileName, String archivePattern) throws IOException

Create a RotatingFileAppender writing 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 fileName parameter, and then archival of files will be delegated to the archive pattern.

For example when fileName is current.log and archivePattern is 'archive-'yyyyMMDD'.log' (note the quotes), access logs will be written to the current.log file and this file will be rotated on a daily basis to files like archive-20131204.log, archive-20131205.log, ... and so on.

Parameters
directory:File

The directory where access log files will be written to.

fileName:String

A file name where log entries will be written to.

archivePattern:String

A properly escaped DateTimeFormatter pattern for the access log archive files.

Exceptions
IOException:
If an I/O error occurred accessing the filesystem.
RotatingFileAppenderback to summary
private RotatingFileAppender(String filePattern, String archivePattern, File directory) throws IOException

Method Detail

appendback to summary
public void append(String accessLogEntry) throws IOException

Implements org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.append.

Doc from org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.append.

Append the specified access log entry.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurred appending to the log.
closeback to summary
public void close() throws IOException

Implements org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.close.

Doc from org.glassfish.grizzly.http.server.accesslog.AccessLogAppender.close.

Close any underlying resource owned by this appender.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

escapeback to summary
private static String escape(String fileName)