logger.info("xxxxx ,{}",user);
user对象的User类如果重写了toString方法,会打印user具体内容,List<User> user也能正确打印。
logger.info("xxxxx,{},{},{}",a,b,c);
{}是占位符
@RestController
public class Test {
private final Logger logger = LoggerFactory.getLogger(Test.class);
@RequestMapping("/test")
public String test(String name,int age){
logger.info("xxxxx ,{},{}",name,age);
try{
int a = 2/0;
}catch (Exception e){
logger.error("nnnnnn,{},{}",name,age,e);
}
return "1";
}
}