Package com.atlassian.bamboo.filter
Class AccessLogFilter
java.lang.Object
com.atlassian.bamboo.filter.AccessLogFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
Logs JIRA username and request URL via log4j.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Does nothingvoiddoFilter(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 toisInterestingUrl(String).protected StringgetEndText(int httpStatusCode, String startText, long startMem, long memDiff, long timeDiff) protected longgetRequestSizeInB(jakarta.servlet.http.HttpServletRequest request) Gets the size of the request payload in bytes.protected StringgetStartText(String url, jakarta.servlet.http.HttpServletRequest request, long requestSizeInB) voidinit(jakarta.servlet.FilterConfig filterConfig) Does nothing but prints INFO log messageprotected booleanisInterestingUrl(String url) Returns true if the given URL is of our interest.static voidsetUsernameLoggingEnabled(boolean value)
-
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:
initin interfacejakarta.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 toisInterestingUrl(String).- Specified by:
doFilterin interfacejakarta.servlet.Filter- Parameters:
servletRequest- requestservletResponse- responsechain- filter chain- Throws:
IOException- if another filter in the filter chain throws itjakarta.servlet.ServletException- if another filter in the filter chain throws it
-
getStartText
-
getEndText
-
isInterestingUrl
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:
destroyin interfacejakarta.servlet.Filter
-
setUsernameLoggingEnabled
public static void setUsernameLoggingEnabled(boolean value)
-