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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM