Consider following statement and log level is set to ERROR. Logging API being used is log4j. How many strings will be created given above information?
if (logger.isDebugEnabled()) {
logger.debug("Executing SQL query [" + sql + "]");
}
Other question is
if (logger.isDebugEnabled()) {
StringBuilder sBuilder = new StringBuilder("Executing SQL query [");
sBuilder.append(sql);
sBuilder.append("]");
logger.debug(sBuilder.toString());
}
How many string will be created in above case ?
My question is will compiler create strings even if logger is not enabled for debug ?