arXiv:2508.08545cs.SEcs.AI2025-08被引 2

用代码语义和开发者归属感提升日志等级预测准确率

OmniLLP: Enhancing LLM-based Log Level Prediction with Context-Aware Retrieval

  • 按代码功能和开发者归属聚类,挑选更相关的上下文示例
  • 日志等级预测AUC最高提升8%,达到0.88–0.96
  • 适合关注系统可观测性与可维护性的开发团队

开发者在源码中插入日志以捕获维护与调试所需的运行时信息。日志等级选择是日志编写的关键环节,直接影响日志冗余度及系统的可观测性与性能。近年基于机器学习的日志等级预测(LLP)利用大语言模型(LLMs)取得了显著进展(AUC在0.64至0.8之间)。然而,现有方法依赖随机选取的上下文示例,忽略了现代软件项目中的结构特征与多样的日志实践。本文提出OmniLLP框架,通过(1)反映代码功能目的的语义相似性,以及(2)开发者归属一致性对源文件进行聚类。仅从这些语义与归属感知的聚类中检索上下文示例,以生成更连贯的提示,从而提升基于LLM的LLP预测精度。实验表明,语义与归属感知聚类均显著提升预测准确率(最高提升8% AUC),结合两者的方法在评估项目中实现0.88至0.96的AUC。结果表明,将代码语义与开发者归属等软件工程特定上下文融入LLM-LLP,可提供更精准、情境感知的日志策略,显著增强系统可维护性与可观测性。

原文摘要 · Abstract (English)

Developers insert logging statements in source code to capture relevant runtime information essential for maintenance and debugging activities. Log level choice is an integral, yet tricky part of the logging activity as it controls log verbosity and therefore influences systems' observability and performance. Recent advances in ML-based log level prediction have leveraged large language models (LLMs) to propose log level predictors (LLPs) that demonstrated promising performance improvements (AUC between 0.64 and 0.8). Nevertheless, current LLM-based LLPs rely on randomly selected in-context examples, overlooking the structure and the diverse logging practices within modern software projects. In this paper, we propose OmniLLP, a novel LLP enhancement framework that clusters source files based on (1) semantic similarity reflecting the code's functional purpose, and (2) developer ownership cohesion. By retrieving in-context learning examples exclusively from these semantic and ownership aware clusters, we aim to provide more coherent prompts to LLPs leveraging LLMs, thereby improving their predictive accuracy. Our results show that both semantic and ownership-aware clusterings statistically significantly improve the accuracy (by up to 8\% AUC) of the evaluated LLM-based LLPs compared to random predictors (i.e., leveraging randomly selected in-context examples from the whole project). Additionally, our approach that combines the semantic and ownership signal for in-context prediction achieves an impressive 0.88 to 0.96 AUC across our evaluated projects. Our findings highlight the value of integrating software engineering-specific context, such as code semantic and developer ownership signals into LLM-LLPs, offering developers a more accurate, contextually-aware approach to logging and therefore, enhancing system maintainability and observability.

日志预测大模型代码分析可维护性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。