Package org.apache.wicket.protocol.http
Class AbstractRequestLogger
- java.lang.Object
-
- org.apache.wicket.protocol.http.AbstractRequestLogger
-
- All Implemented Interfaces:
IRequestLogger
- Direct Known Subclasses:
RequestLogger
public abstract class AbstractRequestLogger extends java.lang.Object implements IRequestLogger
Base class that collects request and session information for request logging to enable rich information about the events that transpired during a single request. Typical HTTPD and/or Servlet container log files are unusable for determining what happened in the application since they contain the requested URLs of the form http://example.com/app?wicket:interface:0:0:0, which doesn't convey any useful information. Requestloggers can show which page was the target of the request, and which page was rendered as a response, and anything else: resources, Ajax request, etc.The information in the log files can take any format, depending on the request logger implementation: currently Wicket supports two formats: a
legacy, log4j compatible format, and aJSON format.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.wicket.protocol.http.IRequestLogger
IRequestLogger.ISessionLogInfo, IRequestLogger.RequestData, IRequestLogger.SessionData
-
-
Constructor Summary
Constructors Constructor Description AbstractRequestLogger()Construct.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddRequest(IRequestLogger.RequestData rd)protected java.lang.StringformatDate(java.util.Date date)Thread-safely formats the passed date in format 'yyyy-MM-dd hh:mm:ss,SSS' with GMT timezonelonggetAverageRequestTime()intgetCurrentActiveRequestCount()IRequestLogger.RequestDatagetCurrentRequest()IRequestLogger.SessionData[]getLiveSessions()intgetPeakActiveRequestCount()intgetPeakSessions()java.util.List<IRequestLogger.RequestData>getRequests()This method returns a List of the current requests that are in mem.longgetRequestsPerMinute()intgetTotalCreatedSessions()protected abstract voidlog(IRequestLogger.RequestData rd, IRequestLogger.SessionData sd)voidlogEventTarget(org.apache.wicket.request.IRequestHandler requestHandler)Sets the target that was the event target for the current requestvoidlogRequestedUrl(java.lang.String url)Logs the URL that was requested by the browser.voidlogResponseTarget(org.apache.wicket.request.IRequestHandler requestHandler)Sets the target that was the response target for the current requestvoidobjectCreated(java.lang.Object value)Called to monitor additions of objects in theISessionStorevoidobjectRemoved(java.lang.Object value)Called to monitor removals of objects out of theISessionStorevoidobjectUpdated(java.lang.Object value)Called to monitor updates of objects in theISessionStorevoidperformLogging()Perform the actual loggingvoidrequestTime(long timeTaken)This method is called when the request is over.voidsessionCreated(java.lang.String sessionId)called when the session is created and has an id.voidsessionDestroyed(java.lang.String sessionId)Method used to cleanup a livesession when the session was invalidated by the webcontainer
-
-
-
Method Detail
-
getCurrentActiveRequestCount
public int getCurrentActiveRequestCount()
- Specified by:
getCurrentActiveRequestCountin interfaceIRequestLogger- Returns:
- The current active requests
-
getPeakActiveRequestCount
public int getPeakActiveRequestCount()
- Specified by:
getPeakActiveRequestCountin interfaceIRequestLogger- Returns:
- The peak active requests
-
getLiveSessions
public IRequestLogger.SessionData[] getLiveSessions()
- Specified by:
getLiveSessionsin interfaceIRequestLogger- Returns:
- Collection of live Sessions Data
-
getPeakSessions
public int getPeakSessions()
- Specified by:
getPeakSessionsin interfaceIRequestLogger- Returns:
- The peak sessions counter
-
getRequests
public java.util.List<IRequestLogger.RequestData> getRequests()
Description copied from interface:IRequestLoggerThis method returns a List of the current requests that are in mem. This is a readonly list.- Specified by:
getRequestsin interfaceIRequestLogger- Returns:
- Collection of the current requests
-
getTotalCreatedSessions
public int getTotalCreatedSessions()
- Specified by:
getTotalCreatedSessionsin interfaceIRequestLogger- Returns:
- The total created sessions counter
-
objectCreated
public void objectCreated(java.lang.Object value)
Description copied from interface:IRequestLoggerCalled to monitor additions of objects in theISessionStore- Specified by:
objectCreatedin interfaceIRequestLogger- Parameters:
value- the object being created/added
-
objectRemoved
public void objectRemoved(java.lang.Object value)
Description copied from interface:IRequestLoggerCalled to monitor removals of objects out of theISessionStore- Specified by:
objectRemovedin interfaceIRequestLogger- Parameters:
value- the object being removed
-
objectUpdated
public void objectUpdated(java.lang.Object value)
Description copied from interface:IRequestLoggerCalled to monitor updates of objects in theISessionStore- Specified by:
objectUpdatedin interfaceIRequestLogger- Parameters:
value- the object being updated
-
requestTime
public void requestTime(long timeTaken)
Description copied from interface:IRequestLoggerThis method is called when the request is over. This will set the total time a request takes and cleans up the current request data.- Specified by:
requestTimein interfaceIRequestLogger- Parameters:
timeTaken- the time taken in milliseconds
-
sessionCreated
public void sessionCreated(java.lang.String sessionId)
Description copied from interface:IRequestLoggercalled when the session is created and has an id. (for http it means that the http session is created)- Specified by:
sessionCreatedin interfaceIRequestLogger- Parameters:
sessionId- the session id
-
sessionDestroyed
public void sessionDestroyed(java.lang.String sessionId)
Description copied from interface:IRequestLoggerMethod used to cleanup a livesession when the session was invalidated by the webcontainer- Specified by:
sessionDestroyedin interfaceIRequestLogger- Parameters:
sessionId- the session id
-
getCurrentRequest
public IRequestLogger.RequestData getCurrentRequest()
- Specified by:
getCurrentRequestin interfaceIRequestLogger- Returns:
- The
IRequestLogger.RequestDatafor the current request.
-
performLogging
public void performLogging()
Description copied from interface:IRequestLoggerPerform the actual logging- Specified by:
performLoggingin interfaceIRequestLogger
-
log
protected abstract void log(IRequestLogger.RequestData rd, IRequestLogger.SessionData sd)
-
addRequest
protected void addRequest(IRequestLogger.RequestData rd)
-
getAverageRequestTime
public long getAverageRequestTime()
- Specified by:
getAverageRequestTimein interfaceIRequestLogger- Returns:
- The average request time.
-
getRequestsPerMinute
public long getRequestsPerMinute()
- Specified by:
getRequestsPerMinutein interfaceIRequestLogger- Returns:
- The number of requests per minute.
-
logEventTarget
public void logEventTarget(org.apache.wicket.request.IRequestHandler requestHandler)
Description copied from interface:IRequestLoggerSets the target that was the event target for the current request- Specified by:
logEventTargetin interfaceIRequestLogger- Parameters:
requestHandler- the event target
-
logRequestedUrl
public void logRequestedUrl(java.lang.String url)
Description copied from interface:IRequestLoggerLogs the URL that was requested by the browser.- Specified by:
logRequestedUrlin interfaceIRequestLogger- Parameters:
url- the requested URL
-
logResponseTarget
public void logResponseTarget(org.apache.wicket.request.IRequestHandler requestHandler)
Description copied from interface:IRequestLoggerSets the target that was the response target for the current request- Specified by:
logResponseTargetin interfaceIRequestLogger- Parameters:
requestHandler- the response target
-
formatDate
protected java.lang.String formatDate(java.util.Date date)
Thread-safely formats the passed date in format 'yyyy-MM-dd hh:mm:ss,SSS' with GMT timezone- Parameters:
date- the date to format- Returns:
- the formatted date
-
-