You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Within the Java code there are a log of place where debug and info logging is done without checking if according log level is activated or not.
It should also be considered whether logging the information is necessary or useful at all in the corresponding situations.
Also the code contains a huge amount of comment lines like the following. These useless comments blowup up the code and should also be avoided.
// System.out.println(...)
Example
if (DATAINFO.getProperty("userAccountNotification") != null)
DATAINFO.setProperty("user_account_notification", DATAINFO.getProperty("userAccountNotification"));
logger.debug("DataInfo..." + DATAINFO);
Solution
if (DATAINFO.getProperty("userAccountNotification") != null)
DATAINFO.setProperty("user_account_notification", DATAINFO.getProperty("userAccountNotification"));
if (logger.isDebugEnabled()) {
logger.debug("DataInfo..." + DATAINFO);
}
Benefits
Creating new unnessary Java Object (String is also an object) - especially within loops - will be avoided as this is not needed to be done when according log level is disabled.
Probably the code would perform a little better in some situtations as according logging functionality will not be performed.
Removing unnecessary comment lines makes code more compact and therefore a little better to read.
The text was updated successfully, but these errors were encountered:
It depends. If the debug message is concated it may bring some improvement in performance (I don't think we will notice it). However it is a lot of extra code and some may say it is less readable. This check (whether specific log level is enabled) is done internally in a logging library anyway so I would not recommend to bring it to application level. The solution for improving performance is to use formatted debug method instead of concating String:
Description
Within the Java code there are a log of place where debug and info logging is done without checking if according log level is activated or not.
It should also be considered whether logging the information is necessary or useful at all in the corresponding situations.
Also the code contains a huge amount of comment lines like the following. These useless comments blowup up the code and should also be avoided.
Example
Solution
Benefits
The text was updated successfully, but these errors were encountered: