Month: May 2024

  • main方法中屏蔽restTemplate默认日志方法总汇

    第一种:在restTemplate配置代码中加入 Logger logger = (Logger) LoggerFactory.getLogger("ROOT"); logger.setLevel(Level.INFO); public class restTemplateConfig { public static RestTemplate template(){ Logger logger = (Logger) LoggerFactory.getLogger("ROOT"); logger.setLevel(Level.INFO); RestTemplate restTemplate = new RestTemplate(); return restTemplate; } } 第二种:去除springboot中对应的引用 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </exclusion> </exclusions> </dependency> 第三种:主动日志处理 import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.client.RestTemplate; public class RestTemplateExample { private static final…