我有一个 Fargate ECS 容器,用于通过 ECS 中的任务运行 Docker 容器。当任务启动时,会调用一个sh脚本runner.sh,,
#!/bin/sh
echo "this line will get logged to ECS..."
python3 src/my_python_script.py # however print statements from this Python script are not logged to ECS
这又会启动一个长时间运行的 Python 脚本my_python_script.py. 我知道 Python 脚本运行良好,因为它执行了需要执行的操作,但我看不到 Python 脚本的输出。
里面my_python_script.py有好几条print()语句。在我的 ECS Fargate 任务的 CloudWatch 日志中,我看到 sh 脚本 ( "this line will get logged to ECS...") 的输出,但没有看到print()Python 脚本中执行的语句的输出。
这是我的任务定义中的日志配置:
{
"ipcMode": null,
"executionRoleArn": "myecsTaskExecutionRolearn",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "awslogs",
"secretOptions": null,
"options": {
"awslogs-group": "/ecs/mylogsgroup",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "ecs"
}
},
"entryPoint": null,
"portMappings": [],
"command": null,
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "1234567.dck.aws.com/mydockerimage",
"startTimeout": null,
"firelensConfiguration": null,
}
我想我正在遵循https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_awslogs.html中的 awslogs 说明,但也许不是?我是否需要做一些明显的事情来确保print()在我的 ECS 任务的 CloudWatch 日志中捕获 Python 脚本中的语句?
慕丝7291255
相关分类