Package utils
Class RestAssuredLoggerFilter
java.lang.Object
utils.RestAssuredLoggerFilter
- All Implemented Interfaces:
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 -
Method Summary
Modifier and TypeMethodDescriptionio.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.
-
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 interfaceio.restassured.filter.Filter
- Parameters:
requestSpec
- the request specificationresponseSpec
- the response specificationfilterContext
- the filter context- Returns:
- the filtered response
-