我有几个类可用于我的春季批处理作业执行,如下所示。我想将一个常量字符串 SPRING_BATCH_JOB 附加到所有这些类的记录器的名称,以便它使我的日志过滤更容易。我尝试将主题传递给@Slf4j 注释(
@Slf4j(topic = "SPRING_BATCH_LOG")
).它只会打印这个常量文字,不会打印类名。这不是我想要实现的目标。
例如,我想将日志语句
log.info("Creating a retry job execution")
打印为{"@timestamp":"2023-03-21T05:34:24.345+00:00","message":"Creating a retry job execution","logger":"SPRING_BATCH_LOG : c.v.r.r.c. RetryOb","thread":"http-nio-8086-exec-2","level":"INFO"}
.
有什么办法可以做到这一点???
@Slf4j
@Service
@RequiredArgsConstructor
public class RetryOb {
private final RetryJobService retryJobService;
public void retry(retryRequest retryRequest) {
log.info("Creating a retry Initiate job execution");
retryService.startJob(retryRequest);
}
}