Package utils

Class RestAssuredLoggerFilter

java.lang.Object
utils.RestAssuredLoggerFilter
All Implemented Interfaces:
io.restassured.filter.Filter

public class RestAssuredLoggerFilter extends Object implements io.restassured.filter.Filter
A Rest-Assured filter that logs HTTP request and response details using Log4j2. This filter can be added to Rest-Assured requests to log details about the request and response, including method, URI, headers, and body content.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new RestAssuredLoggerFilter.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.restassured.response.Response
    filter(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.specification.FilterableResponseSpecification responseSpec, io.restassured.filter.FilterContext filterContext)
    Filters the HTTP request and response, logging details at appropriate log levels.

    Methods inherited from class java.lang.Object

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

    • RestAssuredLoggerFilter

      public RestAssuredLoggerFilter()
      Constructs a new RestAssuredLoggerFilter.
  • Method Details

    • filter

      public io.restassured.response.Response filter(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.specification.FilterableResponseSpecification responseSpec, io.restassured.filter.FilterContext filterContext)
      Filters the HTTP request and response, logging details at appropriate log levels. Request method and URI are logged at INFO level, while headers and body content are logged at DEBUG level.
      Specified by:
      filter in interface io.restassured.filter.Filter
      Parameters:
      requestSpec - the request specification
      responseSpec - the response specification
      filterContext - the filter context
      Returns:
      the filtered response