logger.info占位符的使用
{}表示占位符,使用方法如下:
1 package org.pine.controller; 2 3 import javax.annotation.Resource; 4 import org.pine.service.CashAccountService; 5 import org.slf4j.Logger; 6 import org.slf4j.LoggerFactory; 7 import org.springframework.stereotype.Controller; 8 import org.springframework.web.bind.annotation.RequestMapping; 9 import org.springframework.web.bind.annotation.ResponseBody; 10 11 @Controller 12 @RequestMapping("/cashAccount") 13 public class CashAccountController { 14 private static Logger logger = LoggerFactory.getLogger(CashAccountController.class); 15 16 @Resource 17 private CashAccountService cashAccountService; 18 19 @RequestMapping("/transfer") 20 @ResponseBody 21 public String transfer(Integer from, Integer to, Double amount) { 22 try { 23 logger.info("from:{},to:{},amount:{}",from,to,amount); 24 this.cashAccountService.transfer(from, to, amount); 25 return "success"; 26 } catch (Exception e) { 27 return "failure"; 28 } 29 30 } 31 32 }