Go Static: Contextualized Logging Statement Generation
Yichen Li, Yintong Huo, Renyi Zhong, Zhihan Jiang, Jinyang Liu, Junjie Huang, Jiazhen Gu, Pinjia He, Michael R. Lyu
Abstract
Logging practices have been extensively investigated to assist developers in writing appropriate logging statements for documenting software behaviors. Although numerous automatic logging approaches have been proposed, their performance remains unsatisfactory due to the constraint of the single-method input, without informative programming context outside the method. Specifically, we identify three inherent limitations with single-method context: limited static scope of logging statements, inconsistent logging styles, and missing type information of logging variables. To tackle these limitations, we propose SCLogger , the first contextualized logging statement generation approach with inter-method static contexts. First, SCLogger extracts inter-method contexts with static analysis to construct the contextualized prompt for language models to generate a tentative logging statement. The contextualized prompt consists of an extended static scope and sampled similar methods, ordered by the chain-of-thought (COT) strategy. Second, SCLogger refines the access of logging variables by formulating a new refinement prompt for language models, which incorporates detailed type information of variables in the tentative logging statement. The evaluation results show that SCLogger surpasses the state-of-the-art approach by 8.7% in logging position accuracy, 32.1% in level accuracy, 19.6% in variable precision, and 138.4% in text BLEU-4 score. Furthermore, SCLogger consistently boosts the performance of logging statement generation across a range of large language models, thereby showcasing the generalizability of this approach. CCS Concepts: • Software and its engineering → Maintaining software .
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 7944ff08-d95b-486b-a57c-f77ce7c3f8bfCited by top-tier papers9
- A Large-Scale Evaluation for Log Parsing Techniques: How Far Are We?Zhihan Jiang, Jinyang Liu, Junjie Huang, Yichen Li et al.ISSTA 2024 · 52 citations
- Face It Yourselves: An LLM-Based Two-Stage Strategy to Localize Configuration Errors via LogsShiwen Shan, Yintong Huo, Yuxin Su, Yichen Li et al.ISSTA 2024 · 18 citations
- No More Labelled Examples? An Unsupervised Log Parser with LLMsJunjie Huang, Zhihan Jiang, Zhuangbin Chen, Michael R. LyuFSE 2025 · 13 citations
- COCA: Generative Root Cause Analysis for Distributed Systems with Code KnowledgeYichen Li, Yulun Wu, Jinyang Liu, Zhihan Jiang et al.ICSE 2025 · 6 citations
- Contextualized Data-Wrangling Code Generation in Computational NotebooksJunjie Huang, Daya Guo, Chenglong Wang, Jiazhen Gu et al.ASE 2024 · 5 citations
Builds on11
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
- DeepLog: Anomaly Detection and Diagnosis from System Logs through Deep LearningMin Du, Feifei Li, Guineng Zheng, Vivek SrikumarCCS 2017 · 1,823 citations
- Using Deep Learning to Generate Complete Log StatementsAntonio Mastropaolo, Luca Pascarella, Gabriele BavotaICSE 2022 · 60 citations
- DeepLV: Suggesting Log Levels Using Ordinal Based Neural NetworksZhenhao Li, Heng Li, Tse-Hsun Peter Chen, Weiyi ShangICSE 2021 · 44 citations
- Where Shall We Log? Studying and Suggesting Logging Locations in Code BlocksZhenhao Li, Tse-Hsun Chen, Weiyi ShangASE 2020 · 41 citations
Related papers
- UniLog: Automatic Logging via LLM and In-Context LearningJunjielong Xu, Ziang Cui, Yuan Zhao, Xu Zhang et al.ICSE 2024 · 56 citations
- Defects4Log: Benchmarking LLMs for Logging Code Defect Detection and ReasoningXin Wang, Zhenhao Li, Zishuo DingASE 2025 · 1 citation
- How Do Developers' Profiles and Experiences Influence their Logging Practices? An Empirical Study of Industrial PractitionersGuoping Rong, Shenghui Gu, Haifeng Shen, He Zhang et al.ICSE 2023 · 4 citations
- FastLog: An End-to-End Method to Efficiently Generate and Insert Logging StatementsXiaoyuan Xie, Zhipeng Cai, Songqiang Chen, Jifeng XuanISSTA 2024 · 3 citations
- DivLog: Log Parsing with Prompt Enhanced In-Context LearningJunjielong Xu, Ruichun Yang, Yintong Huo, Chengyu Zhang et al.ICSE 2024 · 54 citations
