Go Static: Contextualized Logging Statement Generation (2402.12958v1)
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 LLMs 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 LLMs, 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 LLMs, thereby showcasing the generalizability of this approach.
- Apache. 2023. log4j. https://logging.apache.org/log4j/2.x/
- Boyuan Chen and Zhen Ming Jiang. 2017. Characterizing and detecting anti-patterns in the logging code. In 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE). IEEE, 71–81.
- Boyuan Chen and Zhen Ming Jiang. 2021. A survey of software log instrumentation. ACM Computing Surveys (CSUR) 54, 4 (2021), 1–34.
- An automated approach to estimating code coverage measures via execution logs. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering (ASE). 305–316.
- Experience report: Deep learning-based system log analysis for anomaly detection. arXiv preprint arXiv:2107.05908 (2021).
- REVAL: REcommend which VAriables to Log with pre-trained model and graph neural network. IEEE Transactions on Network and Service Management (TNSM) (2022).
- Log2: A cost-aware logging mechanism for performance diagnosis. In 2015 USENIX Annual Technical Conference (USENIX ATC). 139–150.
- Logentext: Automatically generating logging texts using neural machine translation. In 2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 349–360.
- LoGenText-Plus: Improving Neural Machine Translation-based Logging Texts Generation with Syntactic Templates. ACM Transactions on Software Engineering and Methodology (2023).
- On the Temporal Relations between Logging and Code. (2023).
- A survey for in-context learning. arXiv preprint arXiv:2301.00234 (2022).
- Deeplog: Anomaly detection and diagnosis from system logs through deep learning. In Proceedings of the 2017 ACM SIGSAC conference on computer and communications security. 1285–1298.
- Eclipse Foundation. 2023. Eclipse Java Development Tools (JDT) Core. https://www.eclipse.org/jdt/core/
- Where do developers log? an empirical study on logging practices in industry. In Companion Proceedings of the 36th International Conference on Software Engineering (ICSE). 24–33.
- Constructing Effective In-Context Demonstration for Code Intelligence Tasks: An Empirical Study. arXiv preprint arXiv:2304.07575 (2023).
- GitHub. 2023. GitHub Copilot: Your AI pair programmer. https://github.com/features/copilot
- Ceki Gulcu. 2023. slf4j. https://www.slf4j.org
- Unixcoder: Unified cross-modal pre-training for code representation. arXiv preprint arXiv:2203.03850 (2022).
- Characterizing the natural language descriptions in software logging statements. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering (ASE). 178–189.
- A survey on automated log analysis for reliability engineering. ACM computing surveys (CSUR) 54, 6 (2021), 1–37.
- Do Not Give Away My Secrets: Uncovering the Privacy Issue of Neural Code Completion Tools. arXiv preprint arXiv:2309.07639 (2023).
- AutoLog: A Log Sequence Synthesis Framework for Anomaly Detection. arXiv preprint arXiv:2308.09324 (2023).
- SMARTLOG: Place error log statement by deep understanding of log intention. In 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 61–71.
- LLMParser: A LLM-based Log Parsing Framework. arXiv preprint arXiv:2310.01796 (2023).
- A Large-scale Benchmark for Log Parsing. arXiv preprint arXiv:2308.10828 (2023).
- Examining the stability of logging statements. Empirical Software Engineering (ESE) 23 (2018), 290–333.
- LogOptPlus: Learning to optimize logging in catch and if programming constructs. In 2016 IEEE 40th Annual Computer Software and Applications Conference (COMPSAC), Vol. 1. IEEE, 215–220.
- Which log level should developers choose for a new logging statement? Empirical Software Engineering (ESE) 22 (2017), 1684–1716.
- Exploring the Effectiveness of LLMs in Automated Logging Generation: An Empirical Study. arXiv preprint arXiv:2307.05950 (2023).
- Precision-guided context sensitivity for pointer analysis. Proceedings of the ACM on Programming Languages 2, OOPSLA (2018), 1–29.
- An Intelligent Framework for Timely, Accurate, and Comprehensive Cloud Incident Detection. ACM SIGOPS Operating Systems Review 56, 1 (2022), 1–7.
- Are They All Good? Studying Practitioners’ Expectations on the Readability of Log Messages. arXiv preprint arXiv:2308.08836 (2023).
- Where shall we log? studying and suggesting logging locations in code blocks. In Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering (ASE). 361–372.
- Deeplv: Suggesting log levels using ordinal based neural networks. In 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 1461–1472.
- Chin-Yew Lin. 2004. Rouge: A package for automatic evaluation of summaries. In Text summarization branches out. 74–81.
- Scalable and Adaptive Log-based Anomaly Detection with Expert in the Loop. arXiv preprint arXiv:2306.05032 (2023).
- TeLL: log level suggestions via modeling multi-level code block information. In Proceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA). 27–38.
- Which variables should i log? IEEE Transactions on Software Engineering (TSE) 47, 9 (2019), 2012–2031.
- Antonio Mastropaolo. 2023. LANCE2.0. https://github.com/antonio-mastropaolo/automating-logging-acitivities
- Using deep learning to generate complete log statements. In Proceedings of the 44th International Conference on Software Engineering. 2279–2290.
- OpenAI. 2022. GPT-3.5. https://platform.openai.com/docs/models/gpt-3-5
- OpenAI. 2023. ChatGPT. https://openai.com/blog/chatgpt/
- Bleu: a method for automatic evaluation of machine translation. In Proceedings of the 40th annual meeting of the Association for Computational Linguistics (ACL). 311–318.
- Industry practices and event logging: Assessment of a critical software development process. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering (ICSE), Vol. 2. IEEE, 169–178.
- Generative Type Inference for Python. arXiv preprint arXiv:2307.09163 (2023).
- Memorization and generalization in neural code intelligence models. Information and Software Technology (Inf. Softw. Technol.) 153 (2023), 107066.
- Exploring the limits of transfer learning with a unified text-to-text transformer. The Journal of Machine Learning Research (JMLR) 21, 1 (2020), 5485–5551.
- The probabilistic relevance framework: BM25 and beyond. Foundations and Trends® in Information Retrieval 3, 4 (2009), 333–389.
- How is logging practice implemented in open source software projects? a preliminary exploration. In 2018 25th Australasian Software Engineering Conference (ASWEC). IEEE, 171–180.
- Can you capture information as you intend to? A case study on logging practice in industry. In 2020 IEEE International Conference on Software Maintenance and Evolution (ICSME). IEEE, 12–22.
- A systematic review of logging practice in software engineering. In 2017 24th Asia-Pacific Software Engineering Conference (APSEC). IEEE, 534–539.
- An exploratory study of the evolution of communicated information about the execution of large software systems. Journal of Software: Evolution and Process (J. Softw.: Evol. Process) 26, 1 (2014), 3–26.
- Tabnine. 2023. Tabnine. https://www.tabnine.com/
- Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971 (2023).
- Soot: A Java bytecode optimization framework. In CASCON First Decade High Impact Papers. 214–224.
- Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903 (2022).
- Prompting for Automatic Log Template Extraction. arXiv preprint arXiv:2307.09950 (2023).
- What Do Code Models Memorize? An Empirical Study on Large Language Models of Code. arXiv preprint arXiv:2308.09932 (2023).
- Log4perf: Suggesting logging locations for web-based systems’ performance monitoring. In Proceedings of the 2018 ACM/SPEC International Conference on Performance Engineering. 127–138.
- Be conservative: Enhancing failure diagnosis with proactive logging. In Presented as part of the 10th USENIX Symposium on Operating Systems Design and Implementation (OSDI). 293–306.
- Characterizing logging practices in open-source software. In 2012 34th International Conference on Software Engineering (ICSE). IEEE, 102–112.
- Improving software diagnosability via log enhancement. ACM Transactions on Computer Systems (TOCS) 30, 1 (2012), 1–28.
- Pensieve: Non-intrusive failure reproduction for distributed systems using the event chaining approach. In Proceedings of the 26th Symposium on Operating Systems Principles. 19–33.
- Studying and Complementing the Use of Identifiers in Logs. In 2023 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 97–107.
- Log20: Fully automated optimal placement of log printing statements under specified overhead threshold. In Proceedings of the 26th Symposium on Operating Systems Principles (SOSP). 565–581.
- Learning to log: Helping developers make informed logging decisions. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering (ICSE), Vol. 1. IEEE, 415–425.
- Yichen Li (79 papers)
- Yintong Huo (27 papers)
- Renyi Zhong (8 papers)
- Zhihan Jiang (25 papers)
- Jinyang Liu (51 papers)
- Junjie Huang (73 papers)
- Jiazhen Gu (22 papers)
- Pinjia He (47 papers)
- Michael R. Lyu (176 papers)