LogRules: Enhancing Log Analysis Capability of Large Language Models through Rules

Xin Huang, Ting Zhang, Wen Zhao


Abstract
Currently, large language models (LLMs) have achieved impressive performance in natural language processing tasks. However, LLMs still exhibit many hallucinations when analyzing system logs, which is due to the implicit knowledge and rules in logs that LLMs cannot capture. Based on this, we propose LogRules, a lightweight log analysis framework that generates and utilizes rules through LLMs. LogRules consists of three stages: an induction stage, an alignment stage, and a reasoning stage. Firstly, in the induction stage, an strong LLM (e.g., GPT-4o-mini) is tasked with generating a series of rules related to logs, which are then validated on the training set. When the rules are confirmed to produce correct reasoning results, they are added to a rule repository. Secondly, considering that the LLMs with small size (8B parameters) still face challenges in utilizing rules, we design an alignment method based on rule-case contrastive preference optimization (CPO) to effectively enhance the rule reasoning capabilities of these LLMs. Finally, in the reasoning stage, the LLM constructs prompt using the rule repository and performs log analysis on the test set. Experiments show that LogRules outperforms LLM-based methods in log parsing and anomaly detection tasks, and achieves better performance compared to case-based methods.
Anthology ID:
2025.findings-naacl.28
Volume:
Findings of the Association for Computational Linguistics: NAACL 2025
Month:
April
Year:
2025
Address:
Albuquerque, New Mexico
Editors:
Luis Chiruzzo, Alan Ritter, Lu Wang
Venue:
Findings
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
452–470
Language:
URL:
https://preview.aclanthology.org/fix-sig-urls/2025.findings-naacl.28/
DOI:
Bibkey:
Cite (ACL):
Xin Huang, Ting Zhang, and Wen Zhao. 2025. LogRules: Enhancing Log Analysis Capability of Large Language Models through Rules. In Findings of the Association for Computational Linguistics: NAACL 2025, pages 452–470, Albuquerque, New Mexico. Association for Computational Linguistics.
Cite (Informal):
LogRules: Enhancing Log Analysis Capability of Large Language Models through Rules (Huang et al., Findings 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/fix-sig-urls/2025.findings-naacl.28.pdf