Class AccessLogFormatter

    • Field Detail

      • SPACE

        protected static final String SPACE
        When formatting log lines, we often use strings like this one (" ").
        See Also:
        Constant Field Values
      • dayFormatter

        protected volatile ThreadLocal<SimpleDateFormat> dayFormatter
        ThreadLocal for a date formatter to format Dates into a day string in the format "dd".
      • monthFormatter

        protected volatile ThreadLocal<SimpleDateFormat> monthFormatter
        ThreadLocal for a date formatter to format a Date into a month string in the format "MM".
      • yearFormatter

        protected volatile ThreadLocal<SimpleDateFormat> yearFormatter
        ThreadLocal for a date formatter to format a Date into a year string in the format "yyyy".
      • timeFormatter

        protected volatile ThreadLocal<SimpleDateFormat> timeFormatter
        ThreadLocal for a date formatter to format a Date into a time in the format "kk:mm:ss" (kk is a 24-hour representation of the hour).
      • timeZone

        protected String timeZone
        The time zone relative to GMT.
      • needTimeTaken

        protected boolean needTimeTaken
    • Constructor Detail

      • AccessLogFormatter

        public AccessLogFormatter()
        Constructor. Initialize the timeZone and currentDate.
    • Method Detail

      • appendLogEntry

        public abstract void appendLogEntry​(Request request,
                                            Response response,
                                            CharBuffer charBuffer)
        Appends an access log entry line, with info obtained from the given request and response objects, to the given CharBuffer.
        Parameters:
        request - The request object from which to obtain access log info
        response - The response object from which to obtain access log info
        charBuffer - The CharBuffer to which to append access log info
      • getDate

        protected Date getDate()
        This method returns a Date object that is accurate to within one second. If a writerThread calls this method to get a Date and it's been less than 1 second since a new Date was created, this method simply gives out the same Date again so that the system doesn't spend time creating Date objects unnecessarily.
      • calculateTimeZoneOffset

        protected String calculateTimeZoneOffset​(long offset)
      • lookup

        protected String lookup​(String month)
        Return the month abbreviation for the specified month, which must be a two-digit String.
        Parameters:
        month - Month number ("01" .. "12").
      • needTimeTaken

        public boolean needTimeTaken()
        Has the time-taken token been specified in the access log pattern?
        Returns:
        true if the time-taken token has been specified in the access log pattern, false otherwise.