Package org.apache.wicket.protocol.http
Class AbstractRequestLogger
- java.lang.Object
-
- org.apache.wicket.protocol.http.AbstractRequestLogger
-
- All Implemented Interfaces:
IRequestLogger
- Direct Known Subclasses:
JsonRequestLogger
,RequestLogger
public abstract class AbstractRequestLogger extends 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 a JsonRequestLogger JSON 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 void
addRequest(IRequestLogger.RequestData rd)
protected String
formatDate(Date date)
Thread-safely formats the passed date in format 'yyyy-MM-dd hh:mm:ss,SSS' with GMT timezonelong
getAverageRequestTime()
int
getCurrentActiveRequestCount()
IRequestLogger.RequestData
getCurrentRequest()
IRequestLogger.SessionData[]
getLiveSessions()
int
getPeakActiveRequestCount()
int
getPeakSessions()
List<IRequestLogger.RequestData>
getRequests()
This method returns a List of the current requests that are in mem.long
getRequestsPerMinute()
int
getTotalCreatedSessions()
protected abstract void
log(IRequestLogger.RequestData rd, IRequestLogger.SessionData sd)
void
logEventTarget(IRequestHandler requestHandler)
Sets the target that was the event target for the current requestvoid
logRequestedUrl(String url)
Logs the URL that was requested by the browser.void
logResponseTarget(IRequestHandler requestHandler)
Sets the target that was the response target for the current requestvoid
objectCreated(Object value)
Called to monitor additions of objects in theISessionStore
void
objectRemoved(Object value)
Called to monitor removals of objects out of theISessionStore
void
objectUpdated(Object value)
Called to monitor updates of objects in theISessionStore
void
performLogging()
Perform the actual loggingvoid
requestTime(long timeTaken)
This method is called when the request is over.void
sessionCreated(String sessionId)
called when the session is created and has an id.void
sessionDestroyed(String sessionId)
Method used to cleanup a livesession when the session was invalidated by the webcontainer
-
-
-
Constructor Detail
-
AbstractRequestLogger
public AbstractRequestLogger()
Construct.
-
-
Method Detail
-
getCurrentActiveRequestCount
public int getCurrentActiveRequestCount()
- Specified by:
getCurrentActiveRequestCount
in interfaceIRequestLogger
- Returns:
- The current active requests
-
getPeakActiveRequestCount
public int getPeakActiveRequestCount()
- Specified by:
getPeakActiveRequestCount
in interfaceIRequestLogger
- Returns:
- The peak active requests
-
getLiveSessions
public IRequestLogger.SessionData[] getLiveSessions()
- Specified by:
getLiveSessions
in interfaceIRequestLogger
- Returns:
- Collection of live Sessions Data
-
getPeakSessions
public int getPeakSessions()
- Specified by:
getPeakSessions
in interfaceIRequestLogger
- Returns:
- The peak sessions counter
-
getRequests
public List<IRequestLogger.RequestData> getRequests()
Description copied from interface:IRequestLogger
This method returns a List of the current requests that are in mem. This is a readonly list.- Specified by:
getRequests
in interfaceIRequestLogger
- Returns:
- Collection of the current requests
-
getTotalCreatedSessions
public int getTotalCreatedSessions()
- Specified by:
getTotalCreatedSessions
in interfaceIRequestLogger
- Returns:
- The total created sessions counter
-
objectCreated
public void objectCreated(Object value)
Description copied from interface:IRequestLogger
Called to monitor additions of objects in theISessionStore
- Specified by:
objectCreated
in interfaceIRequestLogger
- Parameters:
value
- the object being created/added
-
objectRemoved
public void objectRemoved(Object value)
Description copied from interface:IRequestLogger
Called to monitor removals of objects out of theISessionStore
- Specified by:
objectRemoved
in interfaceIRequestLogger
- Parameters:
value
- the object being removed
-
objectUpdated
public void objectUpdated(Object value)
Description copied from interface:IRequestLogger
Called to monitor updates of objects in theISessionStore
- Specified by:
objectUpdated
in interfaceIRequestLogger
- Parameters:
value
- the object being updated
-
requestTime
public void requestTime(long timeTaken)
Description copied from interface:IRequestLogger
This 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:
requestTime
in interfaceIRequestLogger
- Parameters:
timeTaken
- the time taken in milliseconds
-
sessionCreated
public void sessionCreated(String sessionId)
Description copied from interface:IRequestLogger
called when the session is created and has an id. (for http it means that the http session is created)- Specified by:
sessionCreated
in interfaceIRequestLogger
- Parameters:
sessionId
- the session id
-
sessionDestroyed
public void sessionDestroyed(String sessionId)
Description copied from interface:IRequestLogger
Method used to cleanup a livesession when the session was invalidated by the webcontainer- Specified by:
sessionDestroyed
in interfaceIRequestLogger
- Parameters:
sessionId
- the session id
-
getCurrentRequest
public IRequestLogger.RequestData getCurrentRequest()
- Specified by:
getCurrentRequest
in interfaceIRequestLogger
- Returns:
- The
IRequestLogger.RequestData
for the current request.
-
performLogging
public void performLogging()
Description copied from interface:IRequestLogger
Perform the actual logging- Specified by:
performLogging
in 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:
getAverageRequestTime
in interfaceIRequestLogger
- Returns:
- The average request time.
-
getRequestsPerMinute
public long getRequestsPerMinute()
- Specified by:
getRequestsPerMinute
in interfaceIRequestLogger
- Returns:
- The number of requests per minute.
-
logEventTarget
public void logEventTarget(IRequestHandler requestHandler)
Description copied from interface:IRequestLogger
Sets the target that was the event target for the current request- Specified by:
logEventTarget
in interfaceIRequestLogger
- Parameters:
requestHandler
- the event target
-
logRequestedUrl
public void logRequestedUrl(String url)
Description copied from interface:IRequestLogger
Logs the URL that was requested by the browser.- Specified by:
logRequestedUrl
in interfaceIRequestLogger
- Parameters:
url
- the requested URL
-
logResponseTarget
public void logResponseTarget(IRequestHandler requestHandler)
Description copied from interface:IRequestLogger
Sets the target that was the response target for the current request- Specified by:
logResponseTarget
in interfaceIRequestLogger
- Parameters:
requestHandler
- the response target
-
formatDate
protected String formatDate(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
-
-