public class FacesRequestLogger extends DefaultPhaseListener
The FacesRequestLogger
is a PhaseListener
which logs the Faces request detail as Level.INFO
.
The log format is as below:
method{url, user, action, params, messages, timer}Where:
method
: the HTTP request method, usually GET
or POST
.url
: the request URI with query string.user
: the user detail, composed of:ip
: the user IP, as obtained by Faces.getRemoteAddr()
.login
: the user login, as obtained by Faces.getRemoteUser()
.session
: the session ID, as obtained by Faces.getSessionId()
.viewState
: the server side JSF view state identifier, if any.action
: the action detail, composed of:source
: the action source, as obtained by Components.getCurrentActionSource()
.event
: the action event name, if any.methods
: the action methods, as obtained by Components.getActionExpressionsAndListeners(UIComponent)
validationFailed
: whether JSF validation has failed.params
: the HTTP request parameters whereby any parameters whose name matches javax.faces.*
are skipped,
and whose name ends with password
or token
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 of PhaseId.RESTORE_VIEW
.2
: duration of PhaseId.APPLY_REQUEST_VALUES
.3
: duration of PhaseId.PROCESS_VALIDATIONS
.4
: duration of PhaseId.UPDATE_MODEL_VALUES
.5
: duration of PhaseId.INVOKE_APPLICATION
.6
: duration of PhaseId.RENDER_RESPONSE
.
Register it as <phase-listener>
in faces-config.xml
.
<lifecycle> <phase-listener>org.omnifaces.eventlistener.FacesRequestLogger</phase-listener> </lifecycle>
Constructor and Description |
---|
FacesRequestLogger()
Listen on any phase.
|
Modifier and Type | Method and 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 in
getRequestParameters(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.
|
getPhaseId
public void beforePhase(PhaseEvent event)
beforePhase
in interface PhaseListener
beforePhase
in class DefaultPhaseListener
public void afterPhase(PhaseEvent event)
afterPhase
in interface PhaseListener
afterPhase
in class DefaultPhaseListener
protected Map<String,Object> getLogDetails(FacesContext context)
context
- The involved faces context.protected Map<String,Object> getUserDetails(FacesContext context)
context
- The involved faces context.protected Map<String,Object> getActionDetails(FacesContext context)
context
- The involved faces context.protected Map<String,String> getRequestParameters(FacesContext context)
context
- The involved faces context.protected Pattern getPasswordRequestParameterPattern(FacesContext context)
getRequestParameters(FacesContext)
.
The default pattern matches every request parameter name ending with "password" or "token", case insensitive.context
- The involved faces context.protected Map<String,List<String>> getFacesMessages(FacesContext context)
context
- The involved faces context.Copyright © 2012–2018 OmniFaces. All rights reserved.