在一次哦测试中,sonar-qube总是报Use the built-in formatting to contruct this argument,
在网上查了一下,原来它是推荐这样做:
log.info("#{} {} is completed.",index,task);
下面是全部代码,供你参考:
package logbackCfg; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BuildinTester { private final static Logger log = LoggerFactory.getLogger(BuildinTester.class); public static void main(String[] args) { int index=3; String task="cleanExpiredData"; // Traditional way to contruct a log msg log.info("#"+index+" "+task+" is completed."); // Built-in formatting to contruct a log msg log.info("#{} {} is completed.",index,task); } }
--2020-02-28--