LogUpdater:日志语句中特定缺陷的自动检测与修复
LogUpdater: Automated Detection and Repair of Specific Defects in Logging Statements
AI总结:
LogUpdater是一个两阶段框架,利用合成缺陷日志训练分类器并结合大语言模型推荐,自动检测和修复日志语句中的四种缺陷,显著提升建议质量,并在实际项目中成功应用。
摘要:
开发人员使用日志语句来跟踪软件运行时行为和系统状态。然而,不清晰或具有误导性的日志可能会隐藏真实的执行模式,并阻碍软件维护。当前关于日志语句问题的研究有限,通常仅能发现一种缺陷类型,并依赖人工修正而非自动化。为弥补这一空白,我们开展了一项研究,通过分析以日志为中心的变更来识别四种日志语句缺陷类型。随后,我们提出了LogUpdater,一个用于自动检测和更新这些日志缺陷的两阶段框架。在离线阶段,LogUpdater使用合成的有缺陷日志构建分类器以识别缺陷类型。在在线测试期间,该分类器评估代码片段中的日志是否需要改进以及如何改进。然后,LogUpdater利用来自过去日志更新的类型感知提示,通过基于大语言模型的推荐框架来建议修复方案。结果显示,缺陷检测效果良好,F1分数为0.625。它还将静态文本和动态变量的建议分别大幅提升了48.12%和24.90%。在新项目上,LogUpdater成功推荐更新的比例为61.49%。我们在GitHub上报告了40个有问题的日志及其修复,最终在11个项目中合并了25处更改。
英文摘要:
Developers use logging statements to track software runtime behaviors and system status. Yet, unclear or misleading logs can hide true execution patterns and hinder software maintenance. Current research on logging statement issues is limited, often only spotting one defect type and relying on manual corrections instead of automation. To bridge this gap, we conduct a study to identify four logging statement defect types by analyzing log-centric changes. Then we introduce LogUpdater, a two-stage framework for automatically detecting and updating these log defects. In the offline phase, LogUpdater builds a classifier using synthetic defective logs to spot defect types. During online testing, this classifier assesses if and how logs in code snippets need improvement. LogUpdater then uses type-aware prompts from past logging updates to suggest fixes via a recommendation framework based on LLMs. Results show strong defect detection with an F1 score of 0.625. It also greatly improves static text and dynamic variable suggestions by 48.12% and 24.90%, respectively. LogUpdater successfully recommends updates 61.49% of the time on new projects. We reported 40 problematic logs and their fixes on GitHub, leading to 25 merged changes across 11 projects.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。