slf4j中的Logger 使用占位符{} 來傳入參數記錄日志信息


首先要導入 slf4j包中的2個類

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

 

再定義如下

private final static Logger LOG= LoggerFactory.getLogger(MyClass.class);

 

再使用

if(LOG.isDebugEnabled()){
                LOG.debug("can not find order {} ",orderCode);
 }

 

顯然上述使用占位符{}方式比下面的字符串連接更加高效,

LOG.debug("can not find order "+ orderCode);

原文地址:https://www.cnblogs.com/wahaha603/p/6888247.html


免責聲明!

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



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