So In Nodejs logger works like this
graph TD Request --> Express Express --> middleware middleware --> logger middleware --> request_handler middleware --> data_validator middleware --> cors middleware --> controller controller --> service service --> controller controller --> middleware middleware --> Express Express --> Request
Even Working with python I did something like this while I was moving the lambda function code to a flask server in Euler Motors ![[Resume#euler-motors—delhi-india|Euler Motors – Delhi, India]]
According to the official docs of spring boot spring-boot-starter-web solves a lot of problem so let’s try that also this will be our first dependency injection
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>package in.abhi8290.helloworld;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
// Defining import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
@RestController
public class HelloController {
// Defining
private static final Logger logger = LoggerFactory.getLogger(HelloController.class);
@GetMapping("/")
public String hello() {
logger.info("Wait I have got a new Logger man !!");
return "Hello, World! ";
}
@GetMapping("/v1")
public String helloV1() {
return "Hello, World2 ";
}
}This is done : Simpler than Nodejs !!
Pending
- How to save these logs
- Custom Logger for printing specific things