001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.access.common.spi; 015 016import ch.qos.logback.core.spi.DeferredProcessingAware; 017 018import jakarta.servlet.http.Cookie; 019import jakarta.servlet.http.HttpServletRequest; 020import jakarta.servlet.http.HttpServletResponse; 021import java.util.Enumeration; 022import java.util.List; 023import java.util.Map; 024 025// Contributors: Joern Huxhorn (see also bug #110) 026 027/** 028 * <p>This class is the internal representation of events to be logged. 029 * </p> 030 * 031 * <p>When the HTTP container wishes to log an HTTP access event, then 032 * an instance of this class is created. This instance is passed around 033 * to the different logback components. 034 * </p> 035 * 036 * <p>Put differently, the logback-access project revolves around this interface.</p> 037 * 038 * @author Ceki Gülcü 039 * @author Sébastien Pennec 040 * @author Jörn Huxhorn 041 */ 042public interface IAccessEvent extends DeferredProcessingAware { 043 044 String NA = "-"; 045 int SENTINEL = -1; 046 047 /** 048 * Returns the underlying HttpServletRequest. After serialization the returned 049 * value will be null. 050 * 051 * @return 052 */ 053 HttpServletRequest getRequest(); 054 055 /** 056 * Returns the underlying HttpServletResponse. After serialization the returned 057 * value will be null. 058 * 059 * @return 060 */ 061 HttpServletResponse getResponse(); 062 063 /** 064 * The number of milliseconds elapsed from 1/1/1970 until logging event was 065 * created. 066 */ 067 long getTimeStamp(); 068 069 /** 070 * The sequence number associated with this event. 071 * 072 * <p> 073 * Sequence numbers, if present, should be increasing monotonically. 074 * 075 * @since 1.3.0 076 */ 077 078 long getSequenceNumber(); 079 080 /** 081 * The time elapsed between receiving the request and logging it in 082 * milliseconds. 083 */ 084 long getElapsedTime(); 085 086 /** 087 * The number of seconds elapsed between receiving the request and logging it. 088 */ 089 long getElapsedSeconds(); 090 091 String getRequestURI(); 092 093 /** 094 * The first line of the request. 095 */ 096 String getRequestURL(); 097 098 String getRemoteHost(); 099 100 String getRemoteUser(); 101 102 String getProtocol(); 103 104 String getMethod(); 105 106 String getServerName(); 107 108 String getSessionID(); 109 110 void setThreadName(String threadName); 111 112 String getThreadName(); 113 114 String getQueryString(); 115 116 String getRemoteAddr(); 117 118 String getRequestHeader(String key); 119 120 Enumeration<String> getRequestHeaderNames(); 121 122 Map<String, String> getRequestHeaderMap(); 123 124 Map<String, String[]> getRequestParameterMap(); 125 126 String getAttribute(String key); 127 128 String[] getRequestParameter(String key); 129 130 /** 131 * <p>Return a list of cookies in the httpRequest. The list is immutable and is created if 132 * it did not exist previously. 133 * </p> 134 * 135 * <p>The default implementation returns an immutable empty list. 136 * </p> 137 * 138 * @return an immutable list of cookies in the httpRequest, the returned list can be empty but not null 139 * @since version 2.0.2 140 */ 141 default List<Cookie> getCookies() { 142 return List.of(); 143 } 144 145 String getCookie(String key); 146 147 long getContentLength(); 148 149 int getStatusCode(); 150 151 String getRequestContent(); 152 153 String getResponseContent(); 154 155 int getLocalPort(); 156 157 ServerAdapter getServerAdapter(); 158 159 String getResponseHeader(String key); 160 161 Map<String, String> getResponseHeaderMap(); 162 163 List<String> getResponseHeaderNameList(); 164}