AI
New AI method improves automated log generation for software maintenance
Researchers propose ThinkLog, which uses reasoning-guided language models to automatically create log statements with 20% accuracy—a significant leap over existing approaches.
Software developers routinely invest considerable time and effort in a deceptively tedious task: deciding where to insert log statements, choosing appropriate severity levels, and crafting informative messages. Researchers have now demonstrated that large language models can substantially automate this work through a technique called ThinkLog, which combines reasoning with prompt engineering to generate complete logging code.
The Problem with Current Methods#
Generating production-ready log statements remains surprisingly difficult for automated systems. Existing machine-learning approaches fall short in accuracy, forcing developers to continue shouldering much of this operational burden themselves. The challenge lies in making three coordinated decisions: pinpointing the right location in code to insert a log, assigning the correct severity level (debug, info, warn, error), and formulating a message that clearly captures relevant runtime information.
How ThinkLog Works#
The new approach leverages reasoning as a core mechanism for improving LLM decision-making across all three log-generation tasks. Rather than treating the problem as a straightforward code-generation task, ThinkLog embeds examples that demonstrate reasoning steps directly into the prompts sent to language models. These few-shot demonstrations guide the LLM toward generating contextually appropriate log statements that match the patterns and practices found in real codebases.
Results and Impact#
When evaluated on nearly 10,000 Java methods sourced from public GitHub repositories, ThinkLog achieved a 20.55% accuracy rate—a 15.4% improvement over the previous best approach. Equally noteworthy, this performance gain came at roughly half the computational cost, making the method both more effective and more economical. These results suggest that reasoning-enhanced prompting is a practical path forward for automating routine maintenance tasks.

