IBM Cloud 代码引擎:如何在应用程序未激活时检查日志?

IBM Cloud Code Engine: How to check logs when app not active?

我已经将应用程序部署到 IBM Cloud Code Engine。它有 minimum instances configured to zero, so truly serverless and only active on demand. Now I wanted to check the logs from the CLI

ibmcloud ce app logs --name myapp --all

它返回这条消息:

FAILED No instances running for application 'myapp'. Verify that the application name is correct and it is running

运行后如何查看应用程序日志?

代码引擎应用程序(和作业)日志可以查看一次Application Logging has been enabled. The logs are then available in a separate IBM Cloud Logging dashboard

我也找到了这个old blog post exlaining how to enable CLI access to those logs。启用它后,我能够使用我的 CLI / 开发环境检索应用程序日志。

根据我的要求,我使用这三行之一来获取日志数据/行:

python3 searchLogDNA.py myconfig.json 12 "search term" | jq

用于漂亮的打印,或

python3 searchLogDNA.py myconfig.json 12 "search term" | jq "._line"

从记录中提取实际的日志行,或者

python3 searchLogDNA.py myconfig.json 12 "search term" | jq "._line | fromjson`"

将日志行中带有 JSON 数据的字符串转换为实际的 JSON 输出。