[Paper Review] Prompting for Automatic Log Template Extraction
This paper proposes LogDiv, a tuning-free log parsing framework that leverages in-context learning with large language models (LLMs) to extract log templates by prompting on diverse, representative log examples. Without model fine-tuning, LogDiv achieves state-of-the-art performance with 97.7% parsing accuracy, 88.1% precision template accuracy, and 90.8% recall template accuracy across 16 public datasets.
Log parsing, which involves log template extraction from semi-structured logs to produce structured logs, is the first and the most critical step in automated log analysis. However, current log parsers suffer from limited effectiveness for two reasons. First, traditional data-driven log parsers solely rely on heuristics or handcrafted features designed by domain experts, which may not consistently perform well on logs from diverse systems. Second, existing supervised log parsers require model tuning, which is often limited to fixed training samples and causes sub-optimal performance across the entire log source. To address this limitation, we propose DivLog, an effective log parsing framework based on the in-context learning (ICL) ability of large language models (LLMs). Specifically, before log parsing, DivLog samples a small amount of offline logs as candidates by maximizing their diversity. Then, during log parsing, DivLog selects five appropriate labeled candidates as examples for each target log and constructs them into a prompt. By mining the semantics of examples in the prompt, DivLog generates a target log template in a training-free manner. In addition, we design a straightforward yet effective prompt format to extract the output and enhance the quality of the generated log templates. We conducted experiments on 16 widely-used public datasets. The results show that DivLog achieves (1) 98.1% Parsing Accuracy, (2) 92.1% Precision Template Accuracy, and (3) 92.9% Recall Template Accuracy on average, exhibiting state-of-the-art performance.
Motivation & Objective
- To address the limitations of traditional log parsers that rely on heuristic rules or domain-specific features.
- To overcome the suboptimal generalization of deep learning-based parsers that require model tuning on limited training data.
- To develop a log parsing framework that leverages the in-context learning capability of LLMs without fine-tuning.
- To improve robustness and accuracy in diverse log sources with variable template structures and unbalanced distributions.
- To design a prompt format that enhances output quality and ensures consistent log template generation.
Proposed method
- LogDiv uses GPT-3 as the backbone LLM to perform in-context learning for log template generation.
- It selects a diverse subset of log messages to form a candidate prompt demonstration set.
- For each target log message, it retrieves the top five most similar logs from the candidate set based on semantic similarity.
- The retrieved logs and their corresponding templates are structured into a specialized prompt format to guide the LLM’s output.
- The prompt format is specifically designed to constrain the LLM’s output to valid log template syntax, improving reliability and quality.
- LogDiv generates the final log template via LLM inference without any model fine-tuning or retraining.
Experimental results
Research questions
- RQ1Can in-context learning with LLMs effectively extract log templates without model fine-tuning or handcrafted features?
- RQ2How does LogDiv perform across diverse log sources with variable template complexity and unbalanced distributions?
- RQ3Can a carefully designed prompt format improve the quality and consistency of log template generation from LLMs?
- RQ4How does LogDiv compare to existing unsupervised and supervised log parsers in terms of parsing accuracy and robustness?
- RQ5Can LogDiv generalize across datasets with highly variable log patterns and low-frequency templates?
Key findings
- LogDiv achieves a parsing accuracy of 97.7% across 16 public datasets, outperforming existing methods.
- It attains a precision template accuracy of 88.1%, significantly higher than prior state-of-the-art methods.
- The recall template accuracy reaches 90.8%, indicating strong coverage of rare and complex log templates.
- LogDiv improves upon the best baseline by 3.86 percentage points in parsing accuracy, 20.4 points in precision template accuracy, and 16.7 points in recall template accuracy.
- The framework demonstrates robust performance on datasets with high template diversity and unbalanced log frequency, such as Mac and Proxifier.
- The ablation study confirms that both the prompt design and the diversity-aware example selection are critical for high performance.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.