View Javadoc

1   package ch.qos.logback.access.pattern;
2   
3   import java.util.Enumeration;
4   
5   import ch.qos.logback.access.spi.AccessEvent;
6   import ch.qos.logback.core.CoreConstants;
7   
8   /**
9    * This class is tied to the <code>fullRequest</code> conversion word.
10   * <p>
11   * It has been removed from the {@link ch.qos.logback.access.PatternLayout} since
12   * it needs further testing before wide use.
13   * <p>
14   * @author Ceki G&uuml;lc&uuml;
15   * @author S&eacute;bastien Pennec
16   */
17  public class FullRequestConverter extends AccessConverter {
18  
19    @Override
20    public String convert(AccessEvent ae) {
21      StringBuffer buf = new StringBuffer();
22      buf.append(ae.getRequestURL());
23      buf.append(CoreConstants.LINE_SEPARATOR);
24      
25      Enumeration headerNames = ae.getRequestHeaderNames();
26      while(headerNames.hasMoreElements()) {
27        String name = (String) headerNames.nextElement();
28        buf.append(name);
29        buf.append(": ");
30        buf.append(ae.getRequestHeader(name));
31        buf.append(CoreConstants.LINE_SEPARATOR);
32      }
33      buf.append(CoreConstants.LINE_SEPARATOR);
34      buf.append(ae.getRequestContent());
35      return buf.toString();
36    }
37  
38  }