java.lang.Object
org.omnifaces.eventlistener.DefaultPhaseListener
org.omnifaces.eventlistener.FacesRequestLogger
- All Implemented Interfaces:
PhaseListener,Serializable,EventListener
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, usuallyGETorPOST.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 withpasswordortokenare 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> in faces-config.xml.
<lifecycle>
<phase-listener>org.omnifaces.eventlistener.FacesRequestLogger</phase-listener>
</lifecycle>
- Since:
- 3.0
- Author:
- Bauke Scholtz
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterPhase(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.voidbeforePhase(PhaseEvent event) Before any phase, start the timer.getActionDetails(FacesContext context) You can override this if you need more fine grained control over logging of action details.getFacesMessages(FacesContext context) You can override this if you need more fine grained control over logging of faces messages.getLogDetails(FacesContext context) You can override this if you need more fine grained control over log details.protected PatternYou can override this if you need to change the default pattern for password based request parameters which will be filtered ingetRequestParameters(FacesContext).getRequestParameters(FacesContext context) You can override this if you need more fine grained control over logging of request parameters.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
-
Constructor Details
-
FacesRequestLogger
public FacesRequestLogger()Listen on any phase.
-
-
Method Details
-
beforePhase
Before any phase, start the timer.- Specified by:
beforePhasein interfacePhaseListener- Overrides:
beforePhasein classDefaultPhaseListener
-
afterPhase
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:
afterPhasein interfacePhaseListener- Overrides:
afterPhasein classDefaultPhaseListener
-
getLogDetails
You can override this if you need more fine grained control over log details.- Parameters:
context- The involved faces context.- Returns:
- Log details.
-
getUserDetails
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
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
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
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
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.
-