REST API access logging disabled in Serverless Framework

Enable access logs to retain REST API request history.

Description

REST API access logs can record requests that API Gateway handles before they reach the application.

Potential impact

Application logs alone may leave gaps when you investigate a failed or suspicious request.

Remediation

Set provider.logs.restApi.accessLogging: true, include a request ID in the format, and configure delivery permissions and retention. Exclude secrets and unnecessary request bodies.

Examples

The example logs $context.requestId for a Framework-created API. For an API imported through provider.apiGateway.restApiId, configure logging on its stage.

Before

yaml
provider:
  name: aws
  logs:
    restApi:
      accessLogging: false
      format: 'requestId: $context.requestId'

After

yaml
provider:
  name: aws
  logs:
    restApi:
      accessLogging: true
      format: 'requestId: $context.requestId'

References