paperbot · PL 论文追踪

全部论文 待读 收藏

P2 UniLog: Automatic Logging via LLM and In-Context Learning

UniLog:基于LLM与上下文学习的自动日志生成
ICSE Proceedings of the IEEE/ACM 46th International Conference on Software Engineering2024匹配度 3/10 · 论文涉及 LLM 与程序语言/开发者工具交叉,但任务是自动生成日志语句,不涉及用户关注的静态分析、形式化验证、浮点程序分析、贝叶斯程序分析或 Agentic/ML 系统程序分析。引用 63 inbox
Junjielong Xu, Ziang Cui, Yuan Zhao, Xu Zhang, Shilin He, Pinjia He, Liqun Li, Yu Kang, Qingwei Lin, Yingnong Dang, Saravan Rajmohan, Dongmei Zhang
crossref: 2026-09-12

AI 速览

一句话:提出 UniLog,用 LLM 的上下文学习实现无需微调的端到端自动日志语句生成,并显著降低调优成本。

日志语句的自动插入需要决定记录位置、日志级别与消息内容。现有工具多只覆盖单一子任务,端到端方法又受限于大模型微调成本。本文提出 UniLog,基于大语言模型的上下文学习(ICL)范式:仅需包含五个演示示例的提示即可生成合适的日志语句,无需任何模型调参;在少量随机样本上预热后还能进一步提升日志能力。作者在来自 1,465 个 GitHub 仓库的 12,012 个代码片段上评估。UniLog 在日志位置选择、详细级别预测和日志消息生成上分别达到 76.9%、72.3% 和 27.1 BLEU-4,并仅需同一 LLM 微调所需参数调优时间的不到 4%。

问题
自动日志任务分散,现有工具通常只处理一个子任务;端到端日志受限于微调成本,难以实用。
方法
提出基于 LLM 上下文学习的 UniLog,仅用五个演示示例提示,无需调参;可用数百随机样本预热增强。
评估
在 12,012 个代码片段、1,465 个 GitHub 仓库的数据集上评估,在位置、级别、消息生成指标上取得 SOTA,且调参时间小于微调的 4%。
原文摘要(Abstract)

Logging, which aims to determine the position of logging statements, the verbosity levels, and the log messages, is a crucial process for software reliability enhancement. In recent years, numerous automatic logging tools have been designed to assist developers in one of the logging tasks (e.g., providing suggestions on whether to log in try-catch blocks). These tools are useful in certain situations yet cannot provide a comprehensive logging solution in general. Moreover, although recent research has started to explore end-to-end logging, it is still largely constrained by the high cost of fine-tuning, hindering its practical usefulness in software development. To address these problems, this paper proposes UniLog, an automatic logging framework based on the in-context learning (ICL) paradigm of large language models (LLMs). Specifically, UniLog can generate an appropriate logging statement with only a prompt containing five demonstration examples without any model tuning. In addition, UniLog can further enhance its logging ability after warmup with only a few hundred random samples. We evaluated UniLog on a large dataset containing 12,012 code snippets extracted from 1,465 GitHub repositories. The results show that UniLog achieved the state-of-the-art performance in automatic logging: (1) 76.9% accuracy in selecting logging positions, (2) 72.3% accuracy in predicting verbosity levels, and (3) 27.1 BLEU-4 score in generating log messages. Meanwhile, UniLog requires less than 4% of the parameter tuning time needed by fine-tuning the same LLM.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot11462,
  title = {UniLog: Automatic Logging via LLM and In-Context Learning},
  author = {Junjielong Xu and Ziang Cui and Yuan Zhao and Xu Zhang and Shilin He and Pinjia He and Liqun Li and Yu Kang and Qingwei Lin and Yingnong Dang and Saravan Rajmohan and Dongmei Zhang},
  booktitle = {ICSE},
  year = {2024},
  doi = {10.1145/3597503.3623326}
}