Serverless Framework plugin to specify a custom log class for AWS Lambda functions. By default Serverless Framework uses the Standard log class with no option to change it.
An additional log group will be created for Infrequent Access logs and the original log group will be maintained but unused.
Supported version of Serverless Framework:
- 1.70.0+
- 2.0.0+
- 3.0.0+
- 4.0.0+
Install the plugin via your favourite npm client:
npm install --save-dev serverless-plugin-log-class
Enable the plugin in your serverless.yml
:
plugins:
- serverless-plugin-log-class
Specify the desired log class globally or at function level:
custom:
logClassPlugin:
logClass: INFREQUENT_ACCESS
or
functions:
myFunction:
handler: handler.myFunction
logClassPlugin:
logClass: INFREQUENT_ACCESS
Supported log classes:
- STANDARD (falls back to default serverless behavior)
- INFREQUENT_ACCESS
The plugin will create a new log group for the specified log class. The original log group will remain but unused.
If you would like to remove the original log group, which would mean losing any existing logs, you can set the following option:
custom:
logClassPlugin:
preserveDefaultLogGroup: false # default: true
And even keep the same name (although old logs will still be lost):
custom:
logClassPlugin:
preserveDefaultLogGroup: false # default: true
logGroupNameSuffix: '' # Removes the -ia suffix
Please note: if you decide to remove the suffix, but then want to re-enable the
default log group, you will first need to re-add the suffix and deploy to avoid
a name clash before setting preserveDefaultLogGroup
to true
.