了解 Azure IoT Edge 模块

Understanding Azure IoT Edge Modules

我对 Azure 和 IoT Edge 还很陌生,我正在尝试了解模块的工作原理。

我遵循了这个很好的教程 (https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-c-module),一切似乎 运行 正常。

我的问题是关于代码中的 printf。 (例如这里的第 3 点:https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-c-module#update-the-module-with-custom-code

if (NULL == messageInstance)
{
    printf("Failed allocating 'MESSAGE_INSTANCE' for pipelined message\r\n");
}

在哪里打印输出?

通常它会出现在标准输出上,但我的模块 运行在虚拟机的后台运行。显然我可以访问这个虚拟机。我怎样才能看到它?

这对我来说非常好,以便更好地了解模块如何工作以及如何与 IoT 中心一起通信。

谢谢你帮助我

输出被写入模块日志文件。您可以通过使用 ssh 登录到您的虚拟机然后使用以下命令来检查它:

sudo iotedge logs <yourModuleName>

添加 -f 选项使其跟随新输出,使用 --tail 可以将输出限制为日志文件的最后几行。

sudo iotedge logs <yourModuleName> -f --tail 100

显示日志文件的最后 100 行并添加新的输出。