Menu
AWS Greengrass
Developer Guide

Create a Logger Definition

A logger list defines where to store the logs generated by the AWS Greengrass core and your Lambda functions. The logs can be stored on the file system of the AWS Greengrass core hardware or on Amazon CloudWatch. In this example, set it to be stored on the AWS Greengrass core hardware.

First, create a logging definition:

Copy
aws greengrass create-logger-definition --name "MyLoggerDefinition"

The --name argument specifies a name for the logger definition.

The output from the create-logger-definition CLI command will look like this:

Copy
{ "LastUpdatedTimestamp": "2017-05-17T21:18:55.331Z", "CreationTimestamp": "2017-05-17T21:18:55.331Z", "Id": "beab53cc-098c-4ad2-ac7c-45a70fbde559", "Arn":"arn:aws:greengrass-us-west-2:123451234510:/greengrass/definition/loggers/beab53cc-098c-4ad2-ac7c-45a70fbde559", "Name": "<MyLoggerDefinition>" }

Next, create a logger definition version:

Copy
aws greengrass create-logger-definition-version --logger-definition-id "<LoggerDefinitionId>" --loggers '[ { "Id": "<LoggerElementId>", "Component": "GreengrassSystem", "Level": "INFO", "Space": 5120, "Type": "FileSystem" }, { "Id": "<LoggerElementId>", "Component": "Lambda", "Level": "DEBUG", "Space": 5120, "Type": "FileSystem" }]'

Arguments for the create-logger-definition-version CLI command:

--logger-definition-id

The logger definition ID.

--loggers

A list of JSON objects that define the loggers.

Id

The element ID for this entry in the list.

Component

The logging component. Valid values are GreengrassSystem or Lambda.

Level

The logging level. Valid values are DEBUG, INFO, WARN, ERROR, FATAL.

Space

The maximum space, in KB, to be used by logs for this logger.

Type

The type of logger. Valid values are FileSystem or AWSCloudwatch.

The output from the create-logger-definition-version CLI command will look like this:

Copy
{ "Arn" : "arn:aws:greengrass:us-west-2:123451234510:/greengrass/definition/logging/beab53cc-098c-4ad2-ac7c-45a70fbde559/versions/ca679860-e5a1-4872-88f6-99a4ca988fc3", "Id" : "beab53cc-098c-4ad2-ac7c-45a70fbde559", "Version" : "ca679860-e5a1-4872-88f6-99a4ca988fc3", "CreationTimestamp" : "2017-05-17T21:26:58.438Z" }

Save the output of create-logger-definition-version. You will use the "Arn" field to add the list to the group later.

To view the logging list version you just created, run the get-logging-list-version CLI command:

Copy
aws greengrass get-logger-definition-version --logger-definition-id "<LoggerDefinitionId>" --logger-definition-version-id "<LoggerDefinitionVersion>"

Arguments for the create-logger-definition-version CLI command:

--logger-definition-id

The logger definition ID.

--logger-definition-version-id

The ID of the logger definition version.

The output from the get-logger-definition-version CLI command will look like this:

Copy
{ "Definition": { "Loggers": [ { "Type": "FileSystem", "Space": 5120, "Component": "Lambda", "Id": "lambda-logs", "Level": "DEBUG" }, { "Type": "FileSystem", "Space": 5120, "Component": "GreengrassSystem", "Id": "system-logs", "Level": "INFO" } ] }, "Version": "ca679860-e5a1-4872-88f6-99a4ca988fc3", "CreationTimestamp": "2017-05-17T21:26:58.438Z", "Id": "beab53cc-098c-4ad2-ac7c-45a70fbde559", "Arn": "arn:aws:greengrass:us-west-2:123451234510:/greengrass/definition/logging/beab53cc-098c-4ad2-ac7c-45a70fbde559/versions/ca679860-e5a1-4872-88f6-99a4ca988fc3" }