ThinkLog: Leveraging Reasoning for Log Statement Generation

· Source: cs.SE updates on arXiv.org · Field: Technology & Digital — Software Development & Engineering, Artificial Intelligence & Machine Learning · Depth: Expert, extended

Summary

ThinkLog is a novel LLM-based method designed for end-to-end log statement generation, addressing the limited accuracy of existing approaches. Developed by researchers at Kyushu University, ThinkLog incorporates explicit reasoning into prompts using few-shot examples to guide LLMs in deciding log insertion locations, severity levels, and message content. This method constructs a "reasoning pool" from real-world software examples, storing rationales for logging decisions. Evaluated on 9,619 Java methods from public GitHub repositories, ThinkLog achieved 20.55% log statement generation accuracy, marking a 15.4% improvement over the best existing method, UniLog. Furthermore, these accuracy gains were realized at approximately 50% of the online inference cost compared to UniLog, demonstrating both effectiveness and cost-efficiency. ThinkLog also showed stronger generalization on unseen code, with a 20.7% performance degradation compared to UniLog's 30.2%.

Key takeaway

For Machine Learning Engineers developing automated logging tools, you should integrate explicit reasoning into your LLM-based generation pipelines. By constructing a reusable reasoning pool that captures "why" logging decisions are made, you can achieve higher accuracy and better generalization on unseen code, while also reducing online inference costs by approximately 50%. Consider using 1-shot prompting with sufficiently detailed reasoning to maximize benefits without excessive cost.

Key insights

Incorporating explicit reasoning into LLM prompts significantly improves end-to-end log statement generation accuracy and cost-efficiency.

Principles

Method

ThinkLog builds a reasoning pool from ground-truth log statements, then uses retrieved reasoning-augmented few-shot examples for LLM warmup and inference to generate log statements.

In practice

Topics

Code references

Best for: AI Engineer, Research Scientist, AI Scientist, Machine Learning Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by cs.SE updates on arXiv.org.