View a markdown version of this page

Runtime logs for your Amplify app - AWS Amplify

Runtime logs for your Amplify app

Runtime and middleware logs provide information about the server and middleware for your Amplify app. Runtime logs contain the stdout and stderr output from the server component of your app. You see runtime logs only if your app has a server component, such as an app that uses server-side rendering (SSR). If you built a client-side React app, these logs aren’t available because your function components aren’t rendered every time a request is made.

If your app has a server component, Amplify automatically turns on runtime logs in every environment, and you can’t turn them off. Amplify delivers all runtime logs, without sampling, to Amazon CloudWatch Logs. By default, runtime logs never expire. You can also download your runtime logs from the console.

Runtime logs incur charges in your AWS account. CloudWatch Logs charges for ingesting and storing your runtime logs. Because runtime logs never expire by default, storage charges grow over time.

Amplify writes runtime logs to a log group with the following name pattern:

/aws/amplifygen3/<app-name>/<environment-name>/runtime-logs.local

You can filter your runtime logs by the following logging levels:

  • DEBUG

  • INFO

  • WARN

  • ERROR

You can change the time range of the logs that you view.

Filter runtime logs by logging level in the console

  1. Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.

  2. Choose an app.

  3. In the left navigation pane, choose Logs.

  4. At the top of the Logs page, choose the environment. By default, the page shows the production environment.

  5. Choose the Runtime tab.

  6. For Logging level, choose ERROR.

    You see only ERROR logs.

View runtime logs using the CLI

Runtime logs are the default log type for aws amplifygen3 logs get. The following AWS CLI command gets runtime logs for the preview environment:

aws amplifygen3 logs get --env preview

You can also specify the log type explicitly with --log-type runtime. The following examples show other ways to view runtime logs.

# Stream new runtime logs as they arrive. aws amplifygen3 logs get --env preview --follow # Get runtime logs from the last hour. aws amplifygen3 logs get --env preview --since 1h # Get only lines that match a CloudWatch Logs filter pattern. aws amplifygen3 logs get --env preview --filter "ERROR"

Runtime logs for an app with a backend

Runtime logs contain only what your server code prints. They don’t record calls to your backend. Calls to your backend are in the access logs, with surface set to backend. The database’s errors, slow statements, and schema changes are in the database logs.

Runtime logs aren’t sampled, but backend access log lines can be. If a page fails on a backend call that your code doesn’t log, the runtime logs have nothing for it. Read the failed backend calls instead. For more information, see What error_reason means and Database logs.

To match a runtime line to its backend call, log the request ID that the client SDK puts on each error as requestId, with a label:

const { data, error } = await backend.from('notes').select('id, body') if (error) console.error('Backend call failed', error.code, error.message, 'backendRequestId', error.requestId)

Copy the ID that follows backendRequestId in the line’s message. The line’s own requestId field is the ID of the compute request, not of the backend call. Then find the call’s access log line by that ID. Access logs are off by default outside production, so turn them on first in another environment. For more information, see Find a backend request by its request ID.