line/armeria

Add `KafkaLogWriter`

Open

#4,958 创建于 2023年6月15日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)Java (4,552 star) (863 fork)batch import
good first issuenew feature

描述

The default LogWriter uses SLFJ4 to write serialized RequestLogs. In the cloud environment, it would be better to send logs to the remote message queue directly rather than write logs to the local filesystem.

Like KafkaAccessLogWriter, KafkaLogWriter can be added to the armeria-kafka module. https://github.com/line/armeria/blob/d8a744b467271efb4a617584f5d70d8ac140f7f5/kafka/src/main/java/com/linecorp/armeria/server/logging/kafka/KafkaAccessLogWriter.java#L41-L41

public final class KafkaLogWriter implements LogWriter {
    @Override
    public void logRequest(RequestOnlyLog log) {
        // use LogFormatter.ofJson() to convert the log to a JSON object
    }

    @Override
    public void logResponse(RequestLog log) {
        ...
    }
}

贡献者指南