Greengrass v2 logging

0

I am unable to see anything that I may log out of a Greengrass v2 component.

For example:

import logging
...
...
logger = logging.getLogger()
logger.setLevel(logging.INFO)

...
...
logger.info("Hello world")

This will not be visible in my <COMPONENT>.log or greengrass.log files. I've tried different logging levels too.

Sash
已提問 2 年前檢視次數 508 次
1 個回答
0

You need to set a handler or set basic config. If you direct the logs to stdout, they will appear in the component log.

logger.addHandler(logging.StreamHandler(sys.stdout))
# or
logging.basicConfig(stream=sys.stdout, level=logging.INFO)

Or you could send them to a different file by using a FileHandler instead of a StreamHandler.

profile pictureAWS
專家
Greg_B
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南