Class AccessLogBuilder


  • public class AccessLogBuilder
    extends java.lang.Object
    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 time zone will be used.

    Author:
    Pier Fumagalli, USRZ.com
    • Constructor Detail

      • AccessLogBuilder

        public AccessLogBuilder​(java.lang.String file)
        Create a new AccessLogBuilder writing logs to the specified file.
        Parameters:
        file - The location of the access log file.
      • AccessLogBuilder

        public AccessLogBuilder​(java.io.File file)
        Create a new AccessLogBuilder writing logs to the specified file.
        Parameters:
        file - The location of the access log file.
    • Method Detail

      • format

        public AccessLogBuilder format​(java.lang.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.
      • timeZone

        public AccessLogBuilder timeZone​(java.util.TimeZone timeZone)
        Set the time zone that will be used to represent dates.
      • timeZone

        public AccessLogBuilder timeZone​(java.lang.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.

      • statusThreshold

        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.

      • rotatedHourly

        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.

      • rotatedDaily

        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.

      • rotationPattern

        public AccessLogBuilder rotationPattern​(java.lang.String rotationPattern)
        Set up automatic log-file rotation based on a specified SimpleDateFormat 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, ...

      • synchronous

        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.