Abstract
Automatic logging is essential for maintaining software reliability, yet the evaluation of automated logging tools has historically relied on static text-matching metrics that do not reflect real-world utility. We present AL-Bench, the first comprehensive benchmark for automatic logging that incorporates a dynamic evaluation framework. By compiling and executing code containing generated log statements, AL-Bench exposes significant gaps in current state-of-the-art tools, which frequently produce uncompilable code and fail to match the runtime behavior of human-written logs.
Introduction
Logging is a fundamental practice in software engineering, providing critical visibility into system behavior for debugging and monitoring. However, determining the optimal placement, severity level, and content of log statements is a complex, manual task. While Large Language Models (LLMs) have shown promise in automating this process, their evaluation has been hindered by two primary issues: the use of low-quality, synthetic datasets and a reliance on static metrics like BLEU or ROUGE. These metrics fail to account for the syntactic correctness and runtime context necessary for a log statement to be useful.
The AL-Bench Framework
To address these limitations, AL-Bench introduces a dual-evaluation pipeline:
- Static Evaluation: Beyond standard text similarity, we introduce metrics such as Position Accuracy (PA), Level Accuracy (LA), and Dynamic Expression Accuracy (DEA). DEA specifically evaluates whether the variables and logic within a generated log message match the original developer's intent.
- Dynamic Evaluation: This novel approach reintegrates generated logs into the source code to test for Compilation Success Rate (CSR). Furthermore, it executes unit tests to capture actual runtime output, measuring Log File Similarity (LFS) against the "oracle" logs produced by the original code.
The AL-Bench Dataset
The benchmark is built upon a high-quality dataset mined from 10 prominent open-source Java projects, including industry standards like Hadoop, Kafka, and Flink.
The dataset contains 21,804 code snippets and 39,600 log statements, covering domains ranging from distributed storage to messaging systems. This diversity ensures that models are tested against varying logging requirements and professional engineering standards.
Key Findings
Our evaluation of leading tools—LANCE, LEONID, FastLog, and UniLog—revealed a substantial "Reported vs. Reality" gap. Accuracy scores dropped by up to 37% when models were moved from synthetic benchmarks to AL-Bench.
A critical bottleneck identified is compilability. Even the top-performing model, FastLog, failed to compile in 20.1% of cases, while others failed over 80% of the time. These failures often result from "hallucinations" of variable names or a lack of global context regarding logger objects and imports. Furthermore, we found that static similarity is a poor predictor of runtime utility; minor code differences can lead to vastly different runtime log files, a nuance captured only by our dynamic evaluation.
Conclusion
AL-Bench highlights the limitations of current automatic logging research, particularly the neglect of code compilability and runtime behavior. Future progress in this field will require tools that incorporate static analysis or iterative feedback loops to ensure that generated logs are not just linguistically similar to human examples, but are syntactically valid and operationally useful in production environments.
Summary updated