多行日志

ECS打到cloudwatch logs的日志,可以配置多行打印到了一个日志中,也可以拆分开:

image-20230821230126864

说明

如果ECS的日志配置如下:

image-20231018232422919

awslogs-datetime-format这个参数其实是多行匹配的

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html#viewing_awslogs

例如下面三行会被匹配成一条日志:

image-20230821230247951

注意

https://docs.docker.com/config/containers/logging/awslogs/#awslogs-datetime-format

从上面文档中“A log message consists of a line that matches the pattern and any following lines that don’t match the pattern.”这个说明awslogs-datetime-format并不是从开头匹配,所以只要日志行中含有时间,就能被匹配到。例如这种日志也会被匹配到:

[INFO] [2023.08.21 08:52:01.712] [10.54.73.232] [-] [main] [org.springframework.cloud.netflix.eureka.serviceregistry.EurekaAutoServiceRegistration()] - Updating port to 9000