Search papers, labs, and topics across Lattice.
This paper introduces ThinkLog, an LLM-based method for automated log statement generation that incorporates reasoning to enhance decision-making regarding log insertion, severity level assignment, and message generation. By utilizing few-shot examples in prompts, ThinkLog significantly improves log statement generation accuracy, achieving a 20.55% success rate on a dataset of 9,619 Java methods from public GitHub repositories. Notably, this method not only outperforms existing techniques by 15.4% but also reduces inference costs by approximately 50%.
ThinkLog achieves a 20.55% accuracy in log statement generation, marking a significant leap over previous methods while slashing inference costs in half.
Runtime logs are an important source of information that supports software maintenance. To obtain useful logs, developers spend significant effort identifying appropriate log locations, assigning correct severity levels, and writing concise yet informative messages. Therefore, end-to-end automated log statement generation can help reduce this burden, and prior work has proposed many methods for this task. However, existing methods still exhibit limited accuracy. To address this problem, we propose ThinkLog, an LLM-based end-to-end log statement generation method. The core idea of ThinkLog is to incorporate reasoning that helps LLMs make decisions about log insertion, severity level assignment, and message generation, thereby improving log statement generation accuracy. ThinkLog injects reasoning into prompts as few-shot examples and guides LLMs to generate appropriate log statements. Evaluated on 9,619 Java methods extracted from public GitHub repositories, ThinkLog achieves 20.55% log statement generation accuracy, representing a 15.4% improvement over the best existing method. Moreover, these improvements were achieved at approximately 50% of the inference cost (USD) compared to the best existing method. These results show that leveraging reasoning is an effective and cost-efficient way to improve the accuracy of end-to-end log statement generation.