Spring Cloud Logging 的最佳方法是什么?

Evg*_*y M 1 logging log4j2 spring-cloud

我在 AWS 上将 Spring Boot 应用程序作为 Systemd 服务运行。结果,所有日志消息与 Linux 日志消息一起转到 system.log,这使得日志难以阅读。

什么是不淹没 system.log 并为每个应用程序/微服务保留单独日志的最佳方法?是 Log4j 2 吗?你能推荐替代品吗?

Vel*_*aga 5

我建议你使用LogStashspring-cloud-sleuth-zipkin,这提供了更高的稳定性和更容易的日志访问。

Zipkin 还允许您使用 trace-id 和 span-id 跟踪您的请求传播到多个微服务。

使用 Logstash,您可以使用不同的格式(JSON 或纯文本)记录日志。

然后将您的日志配置为gray-logsentry, spring-boot 为两者提供支持。

通过这种方式,您可以轻松地访问组织和访问您的日志。这还提供了 system.log 和 linux.log 的隔离