FileDocCategorySizeDatePackage
CommonAccessLogFormatterImpl.javaAPI DocGlassfish v2 API6766Fri May 04 22:36:04 BST 2007com.sun.enterprise.web.accesslog

CommonAccessLogFormatterImpl

public class CommonAccessLogFormatterImpl extends AccessLogFormatter
Access log formatter using the common access log format from Apache.

Fields Summary
protected static final String
NULL_VALUE
Constructors Summary
public CommonAccessLogFormatterImpl()
Constructor.



          
      

        super();

        dayFormatter = new SimpleDateFormat("dd");
        dayFormatter.setTimeZone(tz);
        monthFormatter = new SimpleDateFormat("MM");
        monthFormatter.setTimeZone(tz);
        yearFormatter = new SimpleDateFormat("yyyy");
        yearFormatter.setTimeZone(tz);
        timeFormatter = new SimpleDateFormat("HH:mm:ss");
        timeFormatter.setTimeZone(tz);
    
Methods Summary
private voidappendAuthUserName(java.nio.CharBuffer cb, javax.servlet.http.HttpServletRequest hreq)

        String user = hreq.getRemoteUser();
        if (user == null) {
            user = NULL_VALUE;
        }
        cb.put(user);
    
private voidappendClientId(java.nio.CharBuffer cb, javax.servlet.ServletRequest req)

        cb.put(NULL_VALUE); // unsupported
    
private voidappendClientName(java.nio.CharBuffer cb, javax.servlet.ServletRequest req)

        String value = req.getRemoteHost();
        if (value == null) {
            value = NULL_VALUE;
        }
        cb.put(value);
    
private voidappendCurrentDate(java.nio.CharBuffer cb)

        Date date = getDate();
        cb.put("[");
        cb.put(dayFormatter.format(date));           // Day
        cb.put('/");
        cb.put(lookup(monthFormatter.format(date))); // Month
        cb.put('/");
        cb.put(yearFormatter.format(date));          // Year
        cb.put(':");
        cb.put(timeFormatter.format(date));          // Time
        cb.put(SPACE);
        cb.put(timeZone);                            // Time Zone
        cb.put("]");
    
public voidappendLogEntry(org.apache.catalina.Request request, org.apache.catalina.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.

param
request The request object from which to obtain access log info
param
response The response object from which to obtain access log info
param
charBuffer The CharBuffer to which to append access log info


        ServletRequest req = request.getRequest();
        HttpServletRequest hreq = (HttpServletRequest) req;

        appendClientName(charBuffer, req);
        charBuffer.put(SPACE);

        appendClientId(charBuffer, req);
        charBuffer.put(SPACE);

        appendAuthUserName(charBuffer, hreq);
        charBuffer.put(SPACE);

        appendCurrentDate(charBuffer);
        charBuffer.put(SPACE);

        appendRequestInfo(charBuffer, hreq);
        charBuffer.put(SPACE);

        appendResponseStatus(charBuffer, response);
        charBuffer.put(SPACE);

        appendResponseLength(charBuffer, response);
        charBuffer.put(SPACE);
    
private voidappendRequestInfo(java.nio.CharBuffer cb, javax.servlet.http.HttpServletRequest hreq)

        cb.put("\"");
        cb.put(hreq.getMethod());
        cb.put(SPACE);
        cb.put(hreq.getRequestURI());
        if (hreq.getQueryString() != null) {
            cb.put('?");
            cb.put(hreq.getQueryString());
        }
        cb.put(SPACE);
        cb.put(hreq.getProtocol());
        cb.put("\"");
    
private voidappendResponseLength(java.nio.CharBuffer cb, org.apache.catalina.Response response)

        cb.put("" + response.getContentCount());
    
private voidappendResponseStatus(java.nio.CharBuffer cb, org.apache.catalina.Response response)

        cb.put(String.valueOf(((HttpResponse) response).getStatus()));