Go Static: Contextualized Logging Statement Generation

Author:

Li Yichen1ORCID,Huo Yintong1ORCID,Zhong Renyi1ORCID,Jiang Zhihan1ORCID,Liu Jinyang1ORCID,Huang Junjie1ORCID,Gu Jiazhen1ORCID,He Pinjia2ORCID,Lyu Michael R.1ORCID

Affiliation:

1. Chinese University of Hong Kong, Hong Kong, China

2. Chinese University of Hong Kong, Shen Zhen, Shenzhen, China

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.

Funder

Research Grants Council of the Hong Kong Special Administrative Region, China

Publisher

Association for Computing Machinery (ACM)

Reference66 articles.

1. Apache. 2023. log4j. https://logging.apache.org/log4j/2.x/

2. Characterizing and Detecting Anti-Patterns in the Logging Code

3. Text Recognition in the Wild

4. An automated approach to estimating code coverage measures via execution logs

5. Zhuangbin Chen Jinyang Liu Wenwei Gu Yuxin Su and Michael R Lyu. 2021. Experience report: Deep learning-based system log analysis for anomaly detection. arXiv preprint arXiv:2107.05908.

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3