SLF4J
和 Log4j 2
日志记录方法参数的非常量字符串串联。
即使未记录日志消息,也会在运行时评估非常量串联;这会对性能产生负面影响。
建议改用参数化日志消息,禁用日志记录时不会对其进行评估。
示例:
public class Vital {
private static final Logger LOG = LoggerFactory.getLogger(Vital.class);
public void saveTheWorld(int i, String s, boolean b) {
LOG.info("saveTheWorld(" + i + ", " + s + ", " + b + ")");
// todo
}
}
在应用快速修复后:
public class Vital {
private static final Logger LOG = LoggerFactory.getLogger(Vital.class);
public void saveTheWorld(int i, String s, boolean b) {
LOG.info("saveTheWorld({}, {}, {})", i, s, b);
// todo
}
}
配置检查: