Go Static: Contextualized Logging Statement Generation
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). First posted on arXiv 20 Feb 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 3; 2025: 4; 2026: 1.
8 papers.
- 2024Automatic Programming: Large Language Models and Beyondcited by 35
- 2025Taming Latency-Memory Trade-Off in MoE-Based LLM Serving via Fine-Grained Expert Offloadingcited by 24
- 2024Demystifying and Extracting Fault-indicating Information from Logs for Failure Diagnosiscited by 6
- 2024Contextualized Data-Wrangling Code Generation in Computational Notebookscited by 3
- 2025Benchmarking AI Models in Software Engineering: A Review, Search Tool, and Unified Approach for Elevating Benchmark Qualitycited by 3
- 2025Automated File-Level Logging Generation for Machine Learning Applications using LLMs: A Case Study using GPT-4o Minicited by 1
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMscited by 1
- 2025AutoLogger: A Multi-Agent Framework for the End-to-End Automated Loggingcited by 0
- 2026Towards Secure Logging: Characterizing and Benchmarking Logging Code Security Issues with LLMs22 Apr 2026
- 2025AutoLogger: A Multi-Agent Framework for the End-to-End Automated Logging23 Nov 2025
- 2025Automated File-Level Logging Generation for Machine Learning Applications using LLMs: A Case Study using GPT-4o Mini6 Aug 2025
- 2025Benchmarking AI Models in Software Engineering: A Review, Search Tool, and Unified Approach for Elevating Benchmark Quality7 Mar 2025
- 2025Taming Latency-Memory Trade-Off in MoE-Based LLM Serving via Fine-Grained Expert Offloading7 Feb 2025
- 2024Demystifying and Extracting Fault-indicating Information from Logs for Failure Diagnosis20 Sep 2024
- 2024Contextualized Data-Wrangling Code Generation in Computational Notebooks20 Sep 2024
- 2024Automatic Programming: Large Language Models and Beyond3 May 2024
Similar, not cited
Close in wording, no citation either way
- 2026ThinkLog: Leveraging Reasoning for Log Statement Generation
- 2025Larger Is Not Always Better: Exploring Small Open-source Language Models in Logging Statement Generation
- 2026Towards Automatically Pruning Logging Code with Coding Agents: How Far Are We?
- 2025Defects4Log: Benchmarking LLMs for Logging Code Defect Detection and Reasoning
- 2024CodeRAG-Bench: Can Retrieval Augment Code Generation?
- 2024RAMBO: Enhancing RAG-based Repository-Level Method Body Completion
- 2025MRG-Bench: Evaluating and Exploring the Requirements of Context for Repository-Level Code Generation
- 2026In Line with Context: Repository-Level Code Generation via Context Inlining