Uncategorized

How to check runtime log implementer in spring boot

Spring/ spring boot comes with default logger configuration for application logging. Spring uses logging fa├žade library called sl4j, hence we can easily change underlying logger implementation by simply adding the required jar files in the classpath. Spring/ spring boot by default picks logabck implementer for application logging. However this can be easily changed by adding other implementations like log4j and removing logback. But if you want to check the current runtime library which is getting used in spring application then simply add following controller and get the run time implenter.

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/logger")
public class SimpleController {

	private static final Logger LOGGER = LoggerFactory.getLogger(SimpleController.class);
	

	
	@GetMapping("/test")
	public Class<? extends Logger> checkLoger() {
		
		return LOGGER.getClass();
		
	}
}

you can even log runtime class if you want to.