一句话:构建日志代码缺陷分类体系与基准数据集 Defects4Log,系统评估 LLM 检测与推理日志代码缺陷的能力。
日志代码用于捕获系统运行时行为,对调试、性能分析和系统监控至关重要,但其中的缺陷会削弱日志价值并导致误读。已有研究多基于有限来源(如提交历史)识别少数缺陷模式,缺乏系统且全面的分析;同时,大语言模型(LLM)在日志代码缺陷检测上的潜力尚未被充分探索。本文首先提出一个涵盖 7 种日志代码缺陷模式、14 个详细场景的分类体系,并构建包含 164 个经开发者验证的真实世界日志缺陷的基准数据集 Defects4Log。然后,提出一个自动化评估框架,利用多种提示策略和上下文信息评估 LLM 检测与推理日志代码缺陷的能力。实验表明,仅凭源代码时 LLM 普遍难以准确检测和推理日志代码缺陷;但引入适当知识(如缺陷模式的详细场景)可使检测准确率提升 10.9%。
Logging code is written by developers to capture system runtime behavior and plays a vital role in debugging, performance analysis, and system monitoring. However, defects in logging code can undermine the usefulness of logs and lead to misinterpretations. Although prior work has identified several logging defect patterns and provided valuable insights into logging practices, these studies often focus on a narrow range of defect patterns derived from limited sources (e.g., commit histories) and lack a systematic and comprehensive analysis. Moreover, large language models (LLMs) have demonstrated promising generalization and reasoning capabilities across a variety of code-related tasks, yet their potential for detecting logging code defects remains largely unexploredIn this paper, we derive a comprehensive taxonomy of logging code defects, which encompasses seven logging code defect patterns with 14 detailed scenarios. We further construct a benchmark dataset, Defects4Log, consisting of 164 developer-verified real-world logging defects. Then we propose an automated framework that leverages various prompting strategies and contextual information to evaluate LLMs’ capability in detecting and reasoning logging code defects. Experimental results reveal that LLMs generally struggle to accurately detect and reason logging code defects based on the source code only. However, incorporating proper knowledge (e.g., detailed scenarios of defect patterns) can lead to 10.9% improvement in detection accuracy. Overall, our findings provide actionable guidance for practitioners to avoid common defect patterns and establish a foundation for improving LLM-based reasoning in logging code defect detection.
DOI 原文 ·
@inproceedings{paperbot9216,
title = {Defects4Log: Benchmarking LLMs for Logging Code Defect Detection and Reasoning},
author = {Xin Wang and Zhenhao Li and Zishuo Ding},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00161}
}