一句话:提出 LANCE,基于 T5 为 Java 方法自动决定日志语句的插入位置、日志级别并生成日志消息。
日志是软件生命周期中广泛采用的实践,但决定在何处插入日志语句、记录什么信息以及使用哪个日志级别并不容易。本文提出 LANCE(Log stAtemeNt reCommEnder),首个同时支持这三类决策的方法。LANCE 基于 Text-To-Text-Transfer-Transformer(T5)模型,在 6,894,456 个 Java 方法上训练;给定一个 Java 方法,它输出一条完整日志语句,包含人类可理解的日志消息,并选择合适的日志级别与插入位置。结果显示,LANCE 能在 65.9% 需要日志的 Java 方法中正确定位插入位置,在 66.2% 的情况下选择正确日志级别,并在 15.2% 的情况下生成完全正确且消息有意义的日志语句。
Logging is a practice widely adopted in several phases of the software lifecycle. For example, during software development log statements allow engineers to verify and debug the system by exposing fine-grained information of the running software. While the benefits of logging are undisputed, taking proper decisions about where to inject log statements, what information to log, and at which log level (e.g., error, warning) is crucial for the logging effectiveness. In this paper, we present LANCE (Log stAtemeNt reCommEnder), the first approach supporting developers in all these decisions. LANCE features a Text-To-Text-Transfer-Transformer (T5) model that has been trained on 6,894,456 Java methods. LANCE takes as input a Java method and injects in it a full log statement, including a human-comprehensible logging message and properly choosing the needed log level and the statement location. Our results show that LANCE is able to (i) properly identify the location in the code where to inject the statement in 65.9% of Java methods requiring it; (ii) selecting the proper log level in 66.2% of cases; and (iii) generate a completely correct log statement including a meaningful logging message in 15.2% of cases.
DOI 原文 ·
@inproceedings{paperbot6934,
title = {Using deep learning to generate complete log statements},
author = {Antonio Mastropaolo and Luca Pascarella and Gabriele Bavota},
booktitle = {ICSE},
year = {2022},
doi = {10.1145/3510003.3511561}
}