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

public Class AccessLogBuilder

extends Object
Class Inheritance
Imports
java.io.File, .IOException, java.time.ZoneId, java.time.format.DateTimeFormatter, java.util.TimeZone, org.glassfish.grizzly.http.server.HttpServer, .HttpServerMonitoringConfig, .ServerConfiguration

A simple builder to configure access logging for Grizzly.

If the format is left unspecified, the default Apache combined format will be used.

If the time zone is left unspecified, the default zone id will be used.

Authors
Pier Fumagalli, USRZ.com

Field Summary

Modifier and TypeField and Description
private final File
private AccessLogFormat
private String
private int
private boolean

Constructor Summary

AccessConstructor and Description
public
AccessLogBuilder(String
The location of the access log file.
file
)

Create a new AccessLogBuilder writing logs to the specified file.

public
AccessLogBuilder(File
The location of the access log file.
file
)

Create a new AccessLogBuilder writing logs to the specified file.

Method Summary

Modifier and TypeMethod and Description
public AccessLogProbe
build()

Build an AccessLogProbe instance which can be injected into an HttpServer's monitoring configuration to provide access logging.

public AccessLogBuilder
format(AccessLogFormat format)

Set the AccessLogFormat instance that will be used by the access logs configured by this instance.

public AccessLogBuilder
format(String format)

Set the format as a String compatible with the default Apache access log format that will be used by the access logs configured by this instance.

public ServerConfiguration
instrument(ServerConfiguration
The ServerConfiguration to instrument.
serverConfiguration
)

Build an AccessLogProbe instance and directly instrument it in an HttpServer's monitoring configuration to provide access logging.

public AccessLogBuilder
rotatedDaily()

Set up automatic log-file rotation, on a daily basis.

public AccessLogBuilder
rotatedHourly()

Set up automatic log-file rotation, on a hourly basis.

public AccessLogBuilder
rotationPattern(String rotationPattern)

Set up automatic log-file rotation based on a specified DateTimeFormatter pattern.

public AccessLogBuilder
statusThreshold(int statusThreshold)

Set the minimum response status that will trigger an entry in an access log configured by this instance.

public AccessLogBuilder
synchronous(boolean synchronous)

Specify whether access log entries should be written synchronously or not.

public AccessLogBuilder
timeZone(TimeZone timeZone)

Set the time zone that will be used to represent dates.

public AccessLogBuilder
timeZone(final ZoneId zoneId)

Set the time zone that will be used to represent dates.

public AccessLogBuilder
timeZone(String timeZone)

Set the time zone that will be used to represent dates.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final File file
formatback to summary
private AccessLogFormat format
rotationPatternback to summary
private String rotationPattern
statusThresholdback to summary
private int statusThreshold
synchronousback to summary
private boolean synchronous

Constructor Detail

AccessLogBuilderback to summary
public AccessLogBuilder(String file)

Create a new AccessLogBuilder writing logs to the specified file.

Parameters
file:String

The location of the access log file.

AccessLogBuilderback to summary
public AccessLogBuilder(File file)

Create a new AccessLogBuilder writing logs to the specified file.

Parameters
file:File

The location of the access log file.

Method Detail

buildback to summary
public AccessLogProbe build()

Build an AccessLogProbe instance which can be injected into an HttpServer's monitoring configuration to provide access logging.

formatback to summary
public AccessLogBuilder format(AccessLogFormat format)

Set the AccessLogFormat instance that will be used by the access logs configured by this instance.

formatback to summary
public AccessLogBuilder format(String format)

Set the format as a String compatible with the default Apache access log format that will be used by the access logs configured by this instance.

instrumentback to summary
public ServerConfiguration instrument(ServerConfiguration serverConfiguration)

Build an AccessLogProbe instance and directly instrument it in an HttpServer's monitoring configuration to provide access logging.

Parameters
serverConfiguration:ServerConfiguration

The ServerConfiguration to instrument.

rotatedDailyback to summary
public AccessLogBuilder rotatedDaily()

Set up automatic log-file rotation, on a daily basis.

For example, if the file name specified at construction was access.log, files will be archived on a daily basis with names like access-yyyyMMDD.log.

rotatedHourlyback to summary
public AccessLogBuilder rotatedHourly()

Set up automatic log-file rotation, on a hourly basis.

For example, if the file name specified at construction was access.log, files will be archived on a hourly basis with names like access-yyyyMMDDhh.log.

rotationPatternback to summary
public AccessLogBuilder rotationPattern(String rotationPattern)

Set up automatic log-file rotation based on a specified DateTimeFormatter pattern.

For example, if the file name specified at construction was access.log and the rotation pattern specified here is EEE (day name in week), files will be archived on a daily basis with names like access-Mon.log, access-Tue.log, ...

statusThresholdback to summary
public AccessLogBuilder statusThreshold(int statusThreshold)

Set the minimum response status that will trigger an entry in an access log configured by this instance.

For example a threshold of 500 will only generate log entries for requests that terminated in error.

synchronousback to summary
public AccessLogBuilder synchronous(boolean synchronous)

Specify whether access log entries should be written synchronously or not.

If false (the default) a QueueingAppender will be used to enqueue entries and append to the final appenders when possible.

timeZoneback to summary
public AccessLogBuilder timeZone(TimeZone timeZone)

Set the time zone that will be used to represent dates.

timeZoneback to summary
public AccessLogBuilder timeZone(final ZoneId zoneId)

Set the time zone that will be used to represent dates.

timeZoneback to summary
public AccessLogBuilder timeZone(String timeZone)

Set the time zone that will be used to represent dates.

The time zone will be looked up by time zone identifier, and if this is invalid or unrecognized, it will default to GMT.