Class FacesRequestLogger

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 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:

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 Details

    • FacesRequestLogger

      public FacesRequestLogger()
      Listen on any phase.
  • Method Details

    • beforePhase

      public void beforePhase(PhaseEvent event)
      Before any phase, start the timer.
      Specified by:
      beforePhase in interface PhaseListener
      Overrides:
      beforePhase in class DefaultPhaseListener
    • 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 interface PhaseListener
      Overrides:
      afterPhase in class DefaultPhaseListener
    • 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 in getRequestParameters(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.