{"title":"LogGen: Integrating traditional model and LLM with code analysis for precise log generation","authors":"Min Li , Gou Tan , Pengfei Chen , Chuanfu Zhang","doi":"10.1016/j.jss.2026.112816","DOIUrl":null,"url":null,"abstract":"<div><div>Logging is a crucial method for the runtime monitoring and measurement of program states. However, in large-scale projects, variations in developer experience lead to significant differences in the key information within log statements, making it challenging to maintain uniform log formats. Therefore, we propose <em>LogGen</em>, a log generation framework that combines a traditional model with Large Language Models (LLMs). It learns from existing projects and automatically inserts log statements into new code, addressing the challenge of LLMs struggling to pinpoint accurate log positions. By leveraging LLM code summarization and integrating function-level semantic information, <em>LogGen</em> constructs more robust features, enabling the traditional model to achieve high accuracy in log positioning. Additionally, <em>LogGen</em> extracts log styles and function call chains from projects to create a knowledge database. LLMs can produce more precise log statements by combining our knowledge with the Retrieval-Augmented Generation (RAG) framework. We evaluate <em>LogGen</em> on long-term developed Java and C++ projects, showing that it surpasses the state-of-the-art log generation methods by 41.6% in F1 of log position and 36.2% in text BLEU-4 score, exhibiting stronger robustness against code and knowledge changes.</div></div>","PeriodicalId":51099,"journal":{"name":"Journal of Systems and Software","volume":"236 ","pages":"Article 112816"},"PeriodicalIF":3.8000,"publicationDate":"2026-06-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Systems and Software","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S0164121226000506","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"2026/2/6 0:00:00","PubModel":"Epub","JCR":"Q1","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0
Abstract
Logging is a crucial method for the runtime monitoring and measurement of program states. However, in large-scale projects, variations in developer experience lead to significant differences in the key information within log statements, making it challenging to maintain uniform log formats. Therefore, we propose LogGen, a log generation framework that combines a traditional model with Large Language Models (LLMs). It learns from existing projects and automatically inserts log statements into new code, addressing the challenge of LLMs struggling to pinpoint accurate log positions. By leveraging LLM code summarization and integrating function-level semantic information, LogGen constructs more robust features, enabling the traditional model to achieve high accuracy in log positioning. Additionally, LogGen extracts log styles and function call chains from projects to create a knowledge database. LLMs can produce more precise log statements by combining our knowledge with the Retrieval-Augmented Generation (RAG) framework. We evaluate LogGen on long-term developed Java and C++ projects, showing that it surpasses the state-of-the-art log generation methods by 41.6% in F1 of log position and 36.2% in text BLEU-4 score, exhibiting stronger robustness against code and knowledge changes.
期刊介绍:
The Journal of Systems and Software publishes papers covering all aspects of software engineering and related hardware-software-systems issues. All articles should include a validation of the idea presented, e.g. through case studies, experiments, or systematic comparisons with other approaches already in practice. Topics of interest include, but are not limited to:
•Methods and tools for, and empirical studies on, software requirements, design, architecture, verification and validation, maintenance and evolution
•Agile, model-driven, service-oriented, open source and global software development
•Approaches for mobile, multiprocessing, real-time, distributed, cloud-based, dependable and virtualized systems
•Human factors and management concerns of software development
•Data management and big data issues of software systems
•Metrics and evaluation, data mining of software development resources
•Business and economic aspects of software development processes
The journal welcomes state-of-the-art surveys and reports of practical experience for all of these topics.