IoT Edge 代理上的日志轮换

Log rotation on IoT Edge Agent

我正在关注 Microsoft documentation 并尝试通过容器选项为 edge Agent 设置日志。我的deployment.template.json文件如下:

{
 "$schema-template": "2.0.0",
  "modulesContent": {
    "$edgeAgent": {
      "properties.desired": {
        "schemaVersion": "1.0",
        "runtime": {
          "type": "docker",
          "settings": {
            "minDockerVersion": "v1.25",
            "loggingOptions": "",
            "registryCredentials": {
              "myRegistryName": {
                "username": "$CONTAINER_REGISTRY_USERNAME",
                "password": "$CONTAINER_REGISTRY_PASSWORD",
                "address": "myRegistryAddress.azurecr.io"
              }
            }
          }
        },
        "systemModules": {
          "edgeAgent": {
            "type": "docker",
            "settings": {
              "image": "mcr.microsoft.com/azureiotedge-agent:1.0",
              "createOptions": {
                "HostConfig": {
                  "LogConfig": {
                      "Type": "json-file",
                      "Config": {
                          "max-size": "10m",
                          "max-file": "3"
                      }
                  }
                }
              }
            }
          },
          "edgeHub": {
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "mcr.microsoft.com/azureiotedge-hub:1.0",
              "createOptions": {
                "HostConfig": {
                  "PortBindings": {
                    "5671/tcp": [
                      {
                        "HostPort": "5671"
                      }
                    ],
                    "8883/tcp": [
                      {
                        "HostPort": "8883"
                      }
                    ],
                    "443/tcp": [
                      {
                        "HostPort": "443"
                      }
                    ]
                  },
                  "LogConfig": {
                    "Type": "json-file",
                    "Config": {
                        "max-size": "10m",
                        "max-file": "3"
                    }
                  }
                }
              }
            }
          }
        },
        "modules": {
          "Module_Name": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "${MODULES.Module_Name}",
              "createOptions": {
                "HostConfig": {
                  "LogConfig": {
                      "Type": "json-file",
                      "Config": {
                          "max-size": "10m",
                          "max-file": "3"
                      }
                  }
                }
              }
            }
          }
        }
      }
    },
    "$edgeHub": {
      "properties.desired": {
        "schemaVersion": "1.0",
        "routes": {
          "route": "FROM /messages/* INTO $upstream"
        },
        "storeAndForwardConfiguration": {
          "timeToLiveSecs": 7200
        }
      }
    }
  }
}

当我在我的设备上构建和部署它时,应用了 edge Hub 和我的模块日志轮换,但没有应用 edgeAgent 日志轮换。我检查了日志轮换设置 /var/lib/docker/containers/{container_id}/hostconfig.json 文件。

到目前为止我做了什么:

通过sudo docker rmi sudo docker rmi mcr.microsoft.com/azureiotedge-agent:1.0删除了镜像,通过sudo systemctl restart iotedge删除了包括edgeAgent容器在内的所有容器并重启了边缘环境。日志轮转仍然没有应用到 edge 运行 时间创建的新容器。我不确定,我错过了什么?任何帮助表示赞赏。 请注意,我不想通过创建 daemon.json 文件并将其放在边缘 运行 时间文件夹中来应用日志轮换。我需要通过 deployment.template.json 文件中指定的容器选项来完成。

这是一个已知错误,如果版本号与 config.yaml 中的相同,则边缘代理部署不适用;请帮助创建一个 github 问题。要解决此问题,请设置 config.yaml.

中的选项