com.sun.enterprise.web.accesslog
Class AccessLogFormatter

java.lang.Object
  extended by com.sun.enterprise.web.accesslog.AccessLogFormatter
Direct Known Subclasses:
CommonAccessLogFormatterImpl, DefaultAccessLogFormatterImpl

public abstract class AccessLogFormatter
extends java.lang.Object

Abstract class defining an interface for appending access log entries to the access log in a customized access log format.


Field Summary
protected  java.lang.ThreadLocal<java.text.SimpleDateFormat> dayFormatter
          ThreadLocal for a date formatter to format Dates into a day string in the format "dd".
protected  java.lang.ThreadLocal<java.text.SimpleDateFormat> monthFormatter
          ThreadLocal for a date formatter to format a Date into a month string in the format "MM".
protected static java.lang.String[] months
          The set of month abbreviations for log messages.
protected  boolean needTimeTaken
           
protected static java.lang.String SPACE
          When formatting log lines, we often use strings like this one (" ").
protected  java.lang.ThreadLocal<java.text.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).
protected  java.lang.String timeZone
          The time zone relative to GMT.
protected  java.util.TimeZone tz
           
protected  java.lang.ThreadLocal<java.text.SimpleDateFormat> yearFormatter
          ThreadLocal for a date formatter to format a Date into a year string in the format "yyyy".
 
Constructor Summary
AccessLogFormatter()
          Constructor.
 
Method Summary
abstract  void appendLogEntry(Request request, Response response, java.nio.CharBuffer charBuffer)
          Appends an access log entry line, with info obtained from the given request and response objects, to the given CharBuffer.
protected  java.lang.String calculateTimeZoneOffset(long offset)
           
protected  java.util.Date getDate()
          This method returns a Date object that is accurate to within one second.
protected  java.lang.String lookup(java.lang.String month)
          Return the month abbreviation for the specified month, which must be a two-digit String.
 boolean needTimeTaken()
          Has the time-taken token been specified in the access log pattern?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

months

protected static final java.lang.String[] months
The set of month abbreviations for log messages.


SPACE

protected static final java.lang.String SPACE
When formatting log lines, we often use strings like this one (" ").

See Also:
Constant Field Values

dayFormatter

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


monthFormatter

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


yearFormatter

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


timeFormatter

protected volatile java.lang.ThreadLocal<java.text.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 java.lang.String timeZone
The time zone relative to GMT.


tz

protected java.util.TimeZone tz

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,
                                    java.nio.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 java.util.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 java.lang.String calculateTimeZoneOffset(long offset)

lookup

protected java.lang.String lookup(java.lang.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.


Copyright © 2012 GlassFish Community. All Rights Reserved.