Table of Contents
Fetching ...

LogUpdater: Automated Detection and Repair of Specific Defects in Logging Statements

Renyi Zhong, Yichen Li, Jinxi Kuang, Wenwei Gu, Yintong Huo, Michael R. Lyu

TL;DR

The paper tackles the observability problem posed by unclear logs by identifying four factual log defects through a broad pilot study and proposing LogUpdater, a two-stage framework that offline-trains a defect detector on synthetic data and online-updates logs via a checker/updater pair guided by defect-type-aware prompts. It demonstrates strong defect detection (F1 up to 0.625) and substantial updating gains for static text and dynamic variables, plus practical impact with 25 merged PRs and 61.49% success on unseen data. The approach combines a similarity-based detector with LLM-based updates, using BM25-based retrieval of historical log-centric changes and context-rich prompts to yield cost-effective, scalable log repair across multiple backbones and projects. Findings highlight the potential for automated log maintenance to improve software observability while reducing manual effort, and suggest future extensions to log-level management and cross-language applicability.

Abstract

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.

LogUpdater: Automated Detection and Repair of Specific Defects in Logging Statements

TL;DR

The paper tackles the observability problem posed by unclear logs by identifying four factual log defects through a broad pilot study and proposing LogUpdater, a two-stage framework that offline-trains a defect detector on synthetic data and online-updates logs via a checker/updater pair guided by defect-type-aware prompts. It demonstrates strong defect detection (F1 up to 0.625) and substantial updating gains for static text and dynamic variables, plus practical impact with 25 merged PRs and 61.49% success on unseen data. The approach combines a similarity-based detector with LLM-based updates, using BM25-based retrieval of historical log-centric changes and context-rich prompts to yield cost-effective, scalable log repair across multiple backbones and projects. Findings highlight the potential for automated log maintenance to improve software observability while reducing manual effort, and suggest future extensions to log-level management and cross-language applicability.

Abstract

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.
Paper Structure (56 sections, 2 equations, 7 figures, 10 tables)

This paper contains 56 sections, 2 equations, 7 figures, 10 tables.

Figures (7)

  • Figure 1: Real-world examples for four defects.
  • Figure 2: The overview framework of LogUpdater.
  • Figure 3: The Checker framework on a static-dynamic inconsistency case.
  • Figure 4: The Updater framework on a static-dynamic inconsistency case.
  • Figure 5: Hyperparameter analysis.
  • ...and 2 more figures