- java.lang.Object
-
- org.omnifaces.eventlistener.DefaultPhaseListener
-
- org.omnifaces.eventlistener.FacesRequestLogger
-
- All Implemented Interfaces:
PhaseListener
,Serializable
,EventListener
public class FacesRequestLogger extends DefaultPhaseListener
The
FacesRequestLogger
is aPhaseListener
which logs the Faces request detail asLevel.INFO
. The log format is as below:method{url, user, action, params, messages, timer}
Where:method
: the HTTP request method, usuallyGET
orPOST
.url
: the request URI with query string.user
: the user detail, composed of:ip
: the user IP, as obtained byFaces.getRemoteAddr()
.login
: the user login, as obtained byFaces.getRemoteUser()
.session
: the session ID, as obtained byFaces.getSessionId()
.viewState
: the server side Faces view state identifier, if any.
action
: the action detail, composed of:source
: the action source, as obtained byComponents.getCurrentActionSource()
.event
: the action event name, if any.methods
: the action methods, as obtained byComponents.getActionExpressionsAndListeners(UIComponent)
validationFailed
: whether Faces validation has failed.
params
: the HTTP request parameters whereby any parameters whose name matchesjakarta.faces.*
are skipped, and whose name ends withpassword
ortoken
are masked with value********
.messages
: all Faces messages added so far.timer
: the duration of each phase measured in milliseconds, or -1 if the phase has been skipped, composed of:0
: total time.1
: duration ofPhaseId.RESTORE_VIEW
.2
: duration ofPhaseId.APPLY_REQUEST_VALUES
.3
: duration ofPhaseId.PROCESS_VALIDATIONS
.4
: duration ofPhaseId.UPDATE_MODEL_VALUES
.5
: duration ofPhaseId.INVOKE_APPLICATION
.6
: duration ofPhaseId.RENDER_RESPONSE
.
Installation
Register it as
<phase-listener>
infaces-config.xml
.<lifecycle> <phase-listener>org.omnifaces.eventlistener.FacesRequestLogger</phase-listener> </lifecycle>
- Since:
- 3.0
- Author:
- Bauke Scholtz
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FacesRequestLogger()
Listen on any phase.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPhase(PhaseEvent event)
After any phase, stop the timer, and if the current phase is RENDER_RESPONSE, or the response is complete, then log the Faces request detail.void
beforePhase(PhaseEvent event)
Before any phase, start the timer.protected Map<String,Object>
getActionDetails(FacesContext context)
You can override this if you need more fine grained control over logging of action details.protected Map<String,List<String>>
getFacesMessages(FacesContext context)
You can override this if you need more fine grained control over logging of faces messages.protected Map<String,Object>
getLogDetails(FacesContext context)
You can override this if you need more fine grained control over log details.protected Pattern
getPasswordRequestParameterPattern(FacesContext context)
You can override this if you need to change the default pattern for password based request parameters which will be filtered ingetRequestParameters(FacesContext)
.protected Map<String,String>
getRequestParameters(FacesContext context)
You can override this if you need more fine grained control over logging of request parameters.protected Map<String,Object>
getUserDetails(FacesContext context)
You can override this if you need more fine grained control over logging of user details.-
Methods inherited from class org.omnifaces.eventlistener.DefaultPhaseListener
getPhaseId
-
-
-
-
Method Detail
-
beforePhase
public void beforePhase(PhaseEvent event)
Before any phase, start the timer.- Specified by:
beforePhase
in interfacePhaseListener
- Overrides:
beforePhase
in classDefaultPhaseListener
-
afterPhase
public void afterPhase(PhaseEvent event)
After any phase, stop the timer, and if the current phase is RENDER_RESPONSE, or the response is complete, then log the Faces request detail.- Specified by:
afterPhase
in interfacePhaseListener
- Overrides:
afterPhase
in classDefaultPhaseListener
-
getLogDetails
protected Map<String,Object> getLogDetails(FacesContext context)
You can override this if you need more fine grained control over log details.- Parameters:
context
- The involved faces context.- Returns:
- Log details.
-
getUserDetails
protected Map<String,Object> getUserDetails(FacesContext context)
You can override this if you need more fine grained control over logging of user details.- Parameters:
context
- The involved faces context.- Returns:
- User details.
-
getActionDetails
protected Map<String,Object> getActionDetails(FacesContext context)
You can override this if you need more fine grained control over logging of action details.- Parameters:
context
- The involved faces context.- Returns:
- Action details.
-
getRequestParameters
protected Map<String,String> getRequestParameters(FacesContext context)
You can override this if you need more fine grained control over logging of request parameters.- Parameters:
context
- The involved faces context.- Returns:
- Request parameters.
-
getPasswordRequestParameterPattern
protected Pattern getPasswordRequestParameterPattern(FacesContext context)
You can override this if you need to change the default pattern for password based request parameters which will be filtered ingetRequestParameters(FacesContext)
. The default pattern matches every request parameter name ending with "password" or "token", case insensitive.- Parameters:
context
- The involved faces context.- Returns:
- Pattern for password request parameters.
-
getFacesMessages
protected Map<String,List<String>> getFacesMessages(FacesContext context)
You can override this if you need more fine grained control over logging of faces messages.- Parameters:
context
- The involved faces context.- Returns:
- Faces messages.
-
-