
1 、Java 中打日志会产生 String 变量吗? 2 、如果会产生,那是不是会占用堆空间?又是如何回收的?
代码:
private void logout(ProceedingJoinPoint point, Object result, long begin, String title) { MethodSignature methodSignature = (MethodSignature) point.getSignature(); log.info("[{}] method: [{}] request: [{}] response: [{}] cost: [{}ms ] ", title , Optional.ofNullable(methodSignature) .map(MethodSignature::getMethod) .map(Method::getName) .orElse(""), JSON.toJSONString(point.getArgs()), JSON.toJSONString(result), System.currentTimeMillis() - begin); } 日志:ch.qos.logback:logback-core:jar:1.2.3:compile