R-Log: Incentivizing Log Analysis Capability in LLMs via Reasoning-based Reinforcement Learning

Yilun Liu, Ziang Chen, Song Xu, Minggui He, Shimin Tao, Weibin Meng, Yuming Xie, Tao Han, Chunguang Zhao, Jingzhou Du, Daimeng Wei, Shenglin Zhang, Yongqian Sun

This paper, a collaboration between Nankai University and Huawei, introduces R-Log, a framework designed to move Large Language Model (LLM) log analysis away from simple pattern matching toward human-like reasoning. By leveraging a two-stage training process involving expert reasoning trajectories and reinforcement learning, the authors significantly improve the accuracy and generalization of automated log analysis.

TL;DR

R-Log transforms LLM log analysis from a "label-fitting" task into a structured reasoning process, mirroring how human engineers diagnose systems. By combining a new dataset of 2k+ expert reasoning trajectories with Reinforcement Learning (GRPO), it achieves state-of-the-art performance and a staggering 228% improvement in generalizing to unseen log formats.

What Problem Does This Paper Address?

Modern software systems generate massive volumes of logs. While LLMs are promising for automated analysis, they face two major hurdles:

  1. Domain Discrepancy: Logs are highly structured (containing IPs, status codes, and file paths) and differ significantly from the natural language LLMs see during pre-training. Standard Supervised Fine-Tuning (SFT) often leads to "learning by rote," where the model memorizes specific log formats but fails on new ones.
  2. The "1ms" Hallucination: In standard SFT, the model calculates loss evenly across all tokens. This means a tiny but critical detail—like a "1ms" response time indicating a configuration error—can be overwhelmed by the surrounding text, leading the model to hallucinate or ignore it.

Methods

The authors propose a two-stage training paradigm:

  • Stage I: Cold-start with Reasoning Trajectories. Instead of training on simple Log -> Label pairs, they created the Log Reasoning Dataset. This dataset contains over 2,000 samples where the model is taught to "think" through 13 specific strategies (e.g., "Replace digit tokens with variables" for parsing or "Trace backward in the log" for root cause analysis). These strategies are divided into Conceptual Thinking (abstracting patterns) and Procedural Thinking (following a checklist).
  • Stage II: Reinforcement Learning (RL). To further refine the model, they used Group Relative Policy Optimization (GRPO)—the same algorithm behind the famous DeepSeek-R1. The model is rewarded based on the correctness of its final answer across five different tasks. Crucially, the RL stage doesn't mandate a specific reasoning path, allowing the model to optimize its own internal logic to reach the right conclusion.
  • R-Log-fast: To address the latency of long reasoning chains, the authors experimented with an "Answer-before-think" order. During inference, the model provides the answer first and can be stopped before it begins the "thinking" tokens, drastically reducing wait times.

Datasets

  • Log Reasoning Dataset (New): A curated collection of 2,632 samples across 10 domains (HDFS, Hadoop, Zookeeper, etc.). It includes reasoning trajectories for five sub-tasks: Log Parsing, Anomaly Detection, Log Interpretation, Root Cause Analysis, and Solution Recommendation.
  • LogLM Benchmark: Used for evaluation, this benchmark covers real-world logs from supercomputers, distributed systems, and software applications.

Key Insights and Ideas

  • Reasoning as a Regularizer: Forcing the model to output its "inner monologue" prevents it from overfitting to specific training logs. It learns the underlying rules of O&M (Operations and Maintenance) rather than just memorizing strings.
  • The Power of RL in O&M: The study found that RL is particularly effective for "unseen" tasks. While SFT is good at mimicking known patterns, RL incentivizes the model to find the correct answer in novel scenarios, leading to much better generalization.
  • Efficiency vs. Efficacy: The "Answer-before-think" (R-Log-fast) approach reveals that the model often "knows" the answer early. By training on reasoning but reversing the output order, you can get the accuracy of a reasoning model with the speed of a standard one.

Key Results

  • Superior Generalization: R-Log outperformed the previous state-of-the-art (LogLM) by 228.05% on unseen log analysis tasks.
  • State-of-the-Art Accuracy: It achieved the highest scores across all five log analysis sub-tasks, notably reaching a 0.987 RandIndex in log parsing and significantly higher BLEU/ROUGE scores in root cause analysis.
  • Speedup: R-Log-fast provided a 5x speedup over the standard reasoning version while retaining 93% of the performance.
  • Real-World Impact: The system is already deployed at Huawei, where it powers an auto-troubleshooting application that generates "diagnostic cards" for engineers.

Limitations and Future Work

  • Latency: Even with R-Log-fast, reasoning-based models require more compute during training and can be slower if the full trajectory is needed for transparency.
  • Model Size: The researchers primarily focused on the 7B parameter scale. They acknowledge that testing on larger foundation models (like 70B+) might yield even better results but requires more resources.
  • Reward Granularity: The current RL rewards are based on the final answer. The authors suggest that future work could involve "process-based" rewards to further improve the quality of the reasoning steps themselves.

Summary updated

BibTeX
@inproceedings{liu2026r,
  author = {Yilun Liu and Ziang Chen and Song Xu and Minggui He and Shimin Tao and Weibin Meng and Yuming Xie and Tao Han and Chunguang Zhao and Jingzhou Du and Daimeng Wei and Shenglin Zhang and Yongqian Sun},
  title = {{R-Log: Incentivizing Log Analysis Capability in LLMs via Reasoning-based Reinforcement Learning}},
  booktitle = {SEIP@ICSE},
  year = {2026},
  doi = {10.1145/3786583.3786913},
}
Figure