[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-detail-85346-en":3,"doc-seo-85346-105":30,"detail-sidebar-cat-0-en-105":91},{"code":4,"msg":5,"data":6},0,"success",{"doc_id":7,"user_id":8,"nickname":9,"user_avatar":10,"doc_module":4,"category_id":11,"category_name":12,"doc_title":13,"doc_description":14,"doc_content":15,"file_id":16,"file_url":17,"file_type":18,"file_size":19,"view_count":20,"is_deleted":4,"is_public":21,"is_downloadable":21,"audit_status":21,"page_count":22,"language":23,"language_code":24,"site_id":25,"html_lang":24,"table_of_contents":26,"faqs":27,"seo_title":13,"seo_description":14,"update_tm":28,"read_time":29},85346,13056703020460,"Valentina","https://ap-avatar.wpscdn.com/avatar/be000253dac470eee5d?_k=1778207105932848923",8,"Research & Report","ThinkLog Leveraging Reasoning for Log Statement Generation","Runtime logs are essential for software maintenance, yet developers must spend substantial effort selecting log insertion locations, assigning correct severity levels, and writing concise, informative messages. Existing end-to-end log statement generation methods still suffer from limited accuracy because they do not model developers’ intent, especially the underlying rationale. ThinkLog is an LLM-based end-to-end method that injects task-specific reasoning into prompts using few-shot examples from a reasoning pool, improving insertion, severity, and message generation accuracy. Evaluated on 9,619 Java methods, it reaches 20.55% accuracy.","arXiv :2607 . 1 16 15v 1 [ cs . SE] 13 Jul 2026  \nThinkLog: Leveraging Reasoning for Log Statement Generation  \nKazuki Kusama 1[0009−0001−6623−3988]􀀌, Honglin Shu 1[0009−0005−7311−7060], Masanari Kondo 1[0000−0002−6317−7001], Tao Xiao 1[0000−0003−4070−585X], and Yasutaka Kamei 1[0000−0002−7058−1045]  \nKyushu University, Fukuoka, Japan  \n{kusama,[shu](shu}@posl.ait.kyushu-u.ac.jp)[}](shu}@posl.ait.kyushu-u.ac.jp)[@posl.ait.kyushu-u.ac.jp](shu}@posl.ait.kyushu-u.ac.jp)  \n{kondo,xiao,[kamei](kamei}@ait.kyushu-u.ac.jp)[}](kamei}@ait.kyushu-u.ac.jp)[@ait.kyushu-u.ac.jp](kamei}@ait.kyushu-u.ac.jp)  \nAbstract. 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  \n9,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.  \nKeywords: Log Statement Generation · Reasoning · Large Language Models  \n1 Introduction  \nAs software systems grow in size and complexity, runtime logs serve as an important source of information for developers during maintenance activities (e.g. , anomaly detection) [2,8] . To ensure that such logs provide useful information, developers must carefully design them by selecting appropriate locations, assigning suitable severity levels, and generating log messages with sufficient contextual information. This design process is inherently difficult and demands substantial time and effort [5,11,31] .  \n2 K. Kusama et al.  \nTo support log design, prior studies have actively explored automated log statement generation [7] . Early approaches decomposed the log statement generation process into separate tasks (e.g., identifying where to insert log statements, determining appropriate severity levels, and generating log messages) and developed automated methods for each task [15,18] . Beyond these task-specific methods, end-to-end methods have also been explored that integrate these tasks to fully automate log statement generation [20,26,27]. For example, LANCE [20] represents the first end-to-end approach, built on T5 [22], a large language model (LLM) .  \nDespite leveraging LLMs, end-to-end log generation remains prone to inaccuracy; for instance, FastLog [26] achieves only ≈16% accuracy. This limitation stems from neglecting the developer’s intent. As Gu et al. [7] highlight, while the Where and What are well-studied, the Why (rationale) is frequently overlooked. Existing methods fail to explicitly model this reasoning, forcing LLMs to rely on surface-level patterns rather than logical inference [30] . This superficial processing precipitates failures, including variable hallucinations and misinterpretations of the code’s state.  \nProviding LLMs with task-specific reasoning processes is a practical way to incorporate this missing why into LLM-based software engineering tasks [12,28, ","cbCaibdAPNs8B5OE","https://ap.wps.com/l/cbCaibdAPNs8B5OE","pdf",918333,3,1,16,"English","en",105,"# Introduction\n## Prior automated log statement generation approaches\n## Why end-to-end methods remain inaccurate\n# ThinkLog Method\n## Reasoning pool and retrieved few-shot prompts\n# Evaluation","[{\"question\":\"What problem does ThinkLog address in end-to-end log statement generation?\",\"answer\":\"ThinkLog targets limited accuracy in existing methods, which often neglect developers’ intent and the “why” behind log design decisions such as location choice, severity assignment, and message content.\"},{\"question\":\"How does ThinkLog incorporate reasoning during inference?\",\"answer\":\"ThinkLog constructs a reasoning pool containing real-world reasoning process examples, retrieves similar code snippets with log statements and their reasoning, and uses them as few-shot prompts to guide an LLM’s decisions.\"},{\"question\":\"What results does ThinkLog achieve on the evaluated Java dataset?\",\"answer\":\"On 9,619 Java methods from public GitHub repositories, ThinkLog attains 20.55% log statement generation accuracy, improving by 15.4% over the best existing method while using about 50% of the inference cost.\"}]",1784202685,40,{"code":4,"msg":31,"data":32},"ok",{"site_id":25,"language":24,"slug":33,"title":13,"keywords":34,"description":14,"schema_data":35,"social_meta":86,"head_meta":88,"extra_data":90,"updated_unix":28},"thinklog-leveraging-reasoning-for-log-statement-generation","",{"@graph":36,"@context":85},[37,53,68],{"@type":38,"itemListElement":39},"BreadcrumbList",[40,44,48,50],{"item":41,"name":42,"@type":43,"position":21},"https://docshare.wps.com","Home","ListItem",{"item":45,"name":46,"@type":43,"position":47},"https://docshare.wps.com/document/","Document",2,{"item":49,"name":12,"@type":43,"position":20},"https://docshare.wps.com/document/research-report/",{"item":51,"name":13,"@type":43,"position":52},"https://docshare.wps.com/document/thinklog-leveraging-reasoning-for-log-statement-generation/85346/",4,{"url":51,"name":13,"@type":54,"author":55,"headline":13,"publisher":57,"fileFormat":60,"inLanguage":24,"description":14,"dateModified":61,"datePublished":62,"encodingFormat":60,"isAccessibleForFree":63,"interactionStatistic":64},"DigitalDocument",{"name":9,"@type":56},"Person",{"url":41,"name":58,"@type":59},"DocShare","Organization","application/pdf","2026-07-24","2026-07-16",true,{"@type":65,"interactionType":66,"userInteractionCount":20},"InteractionCounter",{"@type":67},"ViewAction",{"@type":69,"mainEntity":70},"FAQPage",[71,77,81],{"name":72,"@type":73,"acceptedAnswer":74},"What problem does ThinkLog address in end-to-end log statement generation?","Question",{"text":75,"@type":76},"ThinkLog targets limited accuracy in existing methods, which often neglect developers’ intent and the “why” behind log design decisions such as location choice, severity assignment, and message content.","Answer",{"name":78,"@type":73,"acceptedAnswer":79},"How does ThinkLog incorporate reasoning during inference?",{"text":80,"@type":76},"ThinkLog constructs a reasoning pool containing real-world reasoning process examples, retrieves similar code snippets with log statements and their reasoning, and uses them as few-shot prompts to guide an LLM’s decisions.",{"name":82,"@type":73,"acceptedAnswer":83},"What results does ThinkLog achieve on the evaluated Java dataset?",{"text":84,"@type":76},"On 9,619 Java methods from public GitHub repositories, ThinkLog attains 20.55% log statement generation accuracy, improving by 15.4% over the best existing method while using about 50% of the inference cost.","https://schema.org",{"og:url":51,"og:type":87,"og:title":13,"og:site_name":58,"og:description":14},"article",{"robots":89,"canonical":51},"index,follow",{"doc_id":7,"site_id":25},{"code":4,"msg":5,"data":92},[93,97,101,105,110,115,119,122,127,130,134],{"id":21,"doc_module":4,"doc_module_name":46,"category_name":94,"show_sort_weight":95,"slug":96},"Story & Novel",90,"story-novel",{"id":47,"doc_module":4,"doc_module_name":46,"category_name":98,"show_sort_weight":99,"slug":100},"Literature",80,"literature",{"id":52,"doc_module":4,"doc_module_name":46,"category_name":102,"show_sort_weight":103,"slug":104},"Exam",70,"exam",{"id":106,"doc_module":4,"doc_module_name":46,"category_name":107,"show_sort_weight":108,"slug":109},5,"Comic",60,"comic",{"id":111,"doc_module":4,"doc_module_name":46,"category_name":112,"show_sort_weight":113,"slug":114},6,"Technology",50,"technology",{"id":116,"doc_module":4,"doc_module_name":46,"category_name":117,"show_sort_weight":29,"slug":118},7,"Healthcare","healthcare",{"id":11,"doc_module":4,"doc_module_name":46,"category_name":12,"show_sort_weight":120,"slug":121},30,"research-report",{"id":123,"doc_module":4,"doc_module_name":46,"category_name":124,"show_sort_weight":125,"slug":126},9,"Religion & Spirituality",20,"religion-spirituality",{"id":125,"doc_module":4,"doc_module_name":46,"category_name":128,"show_sort_weight":125,"slug":129},"World Cup","world-cup",{"id":131,"doc_module":4,"doc_module_name":46,"category_name":132,"show_sort_weight":131,"slug":133},10,"Lifestyle","lifestyle",{"id":135,"doc_module":4,"doc_module_name":46,"category_name":136,"show_sort_weight":106,"slug":137},19,"General","general"]