aws-greengrass/aws-greengrass-nucleus

Greengrass: Incorrect log level processing from component.

Closed this issue · 3 comments

Describe the bug
Incorrect log level processing from component.

To Reproduce
Any logging library (e.g. python logging with appropriate level)

Expected behavior
Should have all log levels available, not only WARN (stderr) and INFO (stdout)

Actual behavior
Whenever component is generating log I am getting following message in the log file:

{"thread":"Copier","level":"INFO","eventType":"stdout","message":"2022-11-10 18:40:15,475 - [WARNING] -  Log message","contexts":{"scriptName":"services.test_component.lifecycle.Run","serviceName":"test_component","currentState":"RUNNING"},"loggerName":"test_component","timestamp":1668105615476,"cause":null}

This log line contains duplicate log levels. Greengrass is considering it is as INFO because it was printed to stdout but real log level is not taken into account.

Environment

  • OS: Amazon Linux
  • JDK version: openjdk 11.0.16 2022-07-19 LTS
  • Nucleus version: 2.7.0

Additional context
Custom components are written in python

E.g. what is the impact of the bug?

Impact is that we dont have ability to effectively use logs filtering (also including LogManager component).

Hello,

Greengrass logs all standard out as info level, and all standard error as warn level, this is the expected behavior.

If you want more control over the logging experience, we suggest that you configure your application's logger to write a log file which you own. You can still configure log manager to upload that file by pointing log manager at the appropriate directory and file name format.

Hello @MikeDombo

Thank you, I understand this behavior and it makes sense

According to the AWS documentation it says that it is possible to configure following logging levels:

logging
(Optional) The logging configuration for the core device. For more information about how to configure and use Greengrass logs, see Monitor AWS IoT Greengrass logs.

This object contains the following information:

level
(Optional) The minimum level of log messages to output.

Choose from the following log levels, listed here in level order:

DEBUG

INFO

WARN

ERROR

Default: INFO

So can we expect that native greengrass component will generate logs according to this configuration instead of only available INFO/WARN?

If you are using standard out and standard error as your logger, then yes. Only info and warn will be there.

As I mentioned, you can configure your logger to write to a file and then you'd be able to fully control the log level and what log manager is uploading.