LogOptPlus: Learning to Optimize Logging in Catch and If Programming Constructs

Software logging is a common software development practice which is used to log program execution points. This execution information is later used by software developers for debugging purpose. Software logging is useful but it has cost and benefit tradeoff. Hence it is important to optimize the number of log statements in the code. However, previous studies on logging show that optimal logging is challenging for software developers. Hence tools and techniques which can help developers in making optimized logging decision can be beneficial. We propose LogOptPlus, a machine learning based tool to help software developers to optimize the number of log statements in the source code, for two focused code construct types. LogOptPlus is a significant extension of our previously published work 'LogOpt'. LogOpt is designed to predict logging for catch-blocks. We extend the functionality of LogOpt to predict logging for both if-blocks and catch-blocks. We identify distinguishing static features from the source code for logging prediction. We present intuition and results of quantitative analysis of all the features. We present results of comprehensive evaluation of LogOptPlus with five different machine learning algorithms on two two large Open Source projects (i.e., Apache Tomcat and CloudStack). Encouraging experimental results on two Open Source projects show that LogOptPlus is effective in logging prediction for two focused code construct types.