Class AccessLogFilter

java.lang.Object
com.atlassian.bamboo.filter.AccessLogFilter
All Implemented Interfaces:
jakarta.servlet.Filter

public class AccessLogFilter extends Object implements jakarta.servlet.Filter
Logs JIRA username and request URL via log4j.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Does nothing
    void
    doFilter(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse, jakarta.servlet.FilterChain chain)
    Creates logs if INFO logging level is set and URL is "interesting" according to isInterestingUrl(String).
    protected String
    getEndText(int httpStatusCode, String startText, long startMem, long memDiff, long timeDiff)
     
    protected long
    getRequestSizeInB(jakarta.servlet.http.HttpServletRequest request)
    Gets the size of the request payload in bytes.
    protected String
    getStartText(String url, jakarta.servlet.http.HttpServletRequest request, long requestSizeInB)
     
    void
    init(jakarta.servlet.FilterConfig filterConfig)
    Does nothing but prints INFO log message
    protected boolean
    Returns true if the given URL is of our interest.
    static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AccessLogFilter

      public AccessLogFilter()
  • Method Details

    • init

      public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException
      Does nothing but prints INFO log message
      Specified by:
      init in interface jakarta.servlet.Filter
      Parameters:
      filterConfig - not used
      Throws:
      jakarta.servlet.ServletException - not thrown
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Creates logs if INFO logging level is set and URL is "interesting" according to isInterestingUrl(String).
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Parameters:
      servletRequest - request
      servletResponse - response
      chain - filter chain
      Throws:
      IOException - if another filter in the filter chain throws it
      jakarta.servlet.ServletException - if another filter in the filter chain throws it
    • getStartText

      protected String getStartText(String url, jakarta.servlet.http.HttpServletRequest request, long requestSizeInB)
    • getEndText

      protected String getEndText(int httpStatusCode, String startText, long startMem, long memDiff, long timeDiff)
    • isInterestingUrl

      protected boolean isInterestingUrl(String url)
      Returns true if the given URL is of our interest. Images (.gif, .png, .jpg, .ico), CSS (.css) and JavaScript (.js) are out of interest and if url ends with one of these extentions false is returned.
      Parameters:
      url - url to check
      Returns:
      true if interesting
    • getRequestSizeInB

      protected long getRequestSizeInB(jakarta.servlet.http.HttpServletRequest request)
      Gets the size of the request payload in bytes.
      Parameters:
      request - The HTTP servlet request
      Returns:
      The size in B, or -1 if content length is not available
    • destroy

      public void destroy()
      Does nothing
      Specified by:
      destroy in interface jakarta.servlet.Filter
    • setUsernameLoggingEnabled

      public static void setUsernameLoggingEnabled(boolean value)