내용으로 건너뛰기

Greengrass LOG_LEVEL with custom components using Log4j

0

Hi,

we use log4j to manage logging in our custom components for greengrass (v2). i.e.

log.error("Something terrible happened") or log.info("Just something I like to log")

However, I find that regardless of the level, it is always logged as "INFO" level in the greengrass compoment logs in cloudwatch. i.e.

{"thread":"Copier","level":"INFO","eventType":"stdout","message":"ERROR [<cut>:64] Something terrible happened {error_message=<cut>}

Is there a way to map this properly? Now we have to sync all log levels to cloudwatch to do i.e. monitoring or cloudwatch alarms.

Thanks J

질문됨 3년 전903회 조회

2개 답변
0

Hi,

the "INFO" level you see in the logs generated by Greengrass cannot be changed. Greengrass captures all the output going to stdout and stderr and copies it to its own logs. stdout lines are logged at "INFO" level, stderr lines are logged at "ERROR" level. The loglevel from your own logger will be part of the message. You can redirect your logs to a separate file to have a cleaner log output. You can also extract your original log lines from the message field in the Greengrass logs.

AWS
전문가

답변함 3년 전

0

Hey @johans,

@MassimilianoAWS is right. If you want to have your logs written in your desired level and have them uploaded to cloudwatch. Change your log configuration to write logs into files in your files system and specify a rotation policy. Then, you can use the Log Manager component to target your log files and have your component logs in the log level you desire.

Please note that if you want to use the Log Manager component to filter out your logs by log level, your logs need to be written in a specific JSON format.

AWS

답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.