• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

Computer Engineering & Science ›› 2025, Vol. 47 ›› Issue (3): 448-458.

• Computer Network and Znformation Security • Previous Articles     Next Articles

Log anomaly detection based on Transformer and Text-CNN

YIN Chunyong,ZHANG Xiaohu   

  1. (School of Computer Science,School of Cyber Science and Engineering,
    Nanjing University of Information Science & Technology,Nanjing 210044,China)
  • Received:2023-08-18 Revised:2023-12-04 Online:2025-03-25 Published:2025-04-01

Abstract: Log data, as one of the most important data resources in software systems, records detailed information during system operation, and automated log anomaly detection is crucial for maintain- ing system security. With the widespread application of large language models in the field of natural language processing, Transformer-based log anomaly detection methods have been widely proposed. Traditional Transformer-based methods struggle to capture the local features of log sequences. To address this issue, this paper proposes a log anomaly detection method, LogTC, based on Transformer and Text-CNN. Firstly, logs are converted into structured log data through rule matching, while preserving the effective information in log statements. Secondly, log statements are divided into log sequences using fixed windows or session windows according to log characteristics. Thirdly, natural language processing technology, specifically Sentence-BERT, is used to generate semantic representations of log statements. Finally, the semantic vectors of the log sequences are input into the LogTC log anomaly detection model for detection. Experimental results show that LogTC can effectively detect anomalies in log data and achieves good results on two datasets.

Key words: log anomaly detection, deep learning, word embedding, Transformer, Text-CNN