1 23 24 package org.infoglue.deliver.util.webloggers; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 29 32 33 public class W3CExtendedLogger extends CommonLogger 34 { 35 38 39 public W3CExtendedLogger() 40 { 41 } 42 43 46 47 public synchronized void logRequest(HttpServletRequest request, HttpServletResponse response, String pagePath, long duration) 48 { 49 StringBuffer sb = new StringBuffer (); 50 51 sb.append(defaultValueIfNull(getCurrentDate("yyyy-MM-dd HH:mm:ss"))); sb.append(" "); 53 sb.append(defaultValueIfNull(request.getRemoteAddr())); sb.append(" "); 55 sb.append(defaultValueIfNull(request.getRemoteUser())); sb.append(" "); 57 sb.append("W3SVC1"); sb.append(" "); 59 sb.append(defaultValueIfNull(getHostName())); sb.append(" "); 61 sb.append(defaultValueIfNull(getHostAddress())); sb.append(" "); 63 sb.append(defaultValueIfNull("" + request.getServerPort())); sb.append(" "); 65 sb.append(defaultValueIfNull(request.getMethod())); sb.append(" "); 67 sb.append(defaultValueIfNull(pagePath)); sb.append(" "); 69 sb.append(defaultValueIfNull(request.getQueryString())); sb.append(" "); 71 sb.append("-"); sb.append(" "); 73 sb.append("-"); sb.append(" "); 75 sb.append(defaultValueIfNull("" + response.getBufferSize())); sb.append(" "); 77 sb.append(defaultValueIfNull(request.getHeader("Content-Length"))); sb.append(" "); 79 sb.append(defaultValueIfNull("" + duration)); sb.append(" "); 81 sb.append(defaultValueIfNull(request.getProtocol())); sb.append(" "); 83 sb.append(defaultValueIfNull(request.getRemoteHost())); sb.append(" "); 85 sb.append(defaultValueIfNull(request.getHeader("User-Agent"))); sb.append(" "); 87 sb.append(defaultValueIfNull(request.getHeader("Cookie"))); sb.append(" "); 89 sb.append(defaultValueIfNull(request.getHeader("Referer"))); 91 writeRequest(getCurrentDate("yyyy-MM-dd"), sb.toString()); 92 } 93 94 95 } 96 97 | Popular Tags |