Enabling logging for your Test Framework is easy with EasyLog
.
EasyLog Maven dependency
<dependency>
<groupId>io.lenar</groupId>
<artifactId>easy-log</artifactId>
<version>1.3.0</version>
</dependency>
AOP Spring Boot Starter.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
If you use another Spring Boot project as a parent then you most likely don’t need that starter. Just check.
Extend EasyLogger
In the package logger
create a class logger like this
package com.xyz.checkout.test.logger;
import io.lenar.easy.log.EasyLogger;
import org.springframework.stereotype.Component;
@Component
public class Logger extends EasyLogger {
}
LogIt annotation
Annotate BillingAddressServiceClient
with @LogIt
@Component
@LogIt(label = "Billing Address Service Client", style = Style.PRETTY_PRINT_NO_NULLS)
public class BillingAddressServiceClient {
@Autowired
BillingAddressService billingAddressService;
public void updateBillingAddress(String orderId, BillingAddressDto address, String token) {
billingAddressService.updateBillingAddress(orderId, address, token);
}
public BillingAddressDto getBillingAddress(String orderId, String token) {
return billingAddressService.getBillingAddress(orderId, token);
}
}
That’s it. Now all client’s calls will be logged automatically with all parameters/requests and responses.
Find all EasyLog
’s features here - EasyLog