View logs and metrics

Logging and metrics are important tools for debugging and monitoring code. App Hosting provides quick access to view logs and metrics for the Google Cloud services powering your Web app: Cloud Run, Cloud Build and Cloud CDN.

Using standard logging syntax like Node.js' console.log, you can write log entries to Cloud Logging.

View logs in the console

From the Firebase console context menu (a 3-dot menu at upper right) for a rollout, you can get quick access to view the Cloud Run revision details and errors as well as Cloud Build logs.

These logs contain helpful information for debugging your App Hosting deployments. For example, the Cloud Run log notes when package.json is not found.

The Cloud Build log displays your build output, allowing you to triage whether errors occurred in configuration in your framework, or in App Hosting configuration. It also displays your basic runConfig settings, and indicates when settings are missing or when apphosting.yaml does not exist:

> next build

   ▲ Next.js 14.1.4
   -   Environments: .env

   ...

Route (app)                              Size     First Load JS
┌ λ /                                    4.79 kB         214 kB
├ λ /_not-found                          882 B          85.3 kB
└ λ /restaurant/[id]                     5.28 kB         207 kB
+   First Load JS shared by all            84.4 kB
  ├ chunks/69-6678c81190a8fe82.js        29 kB
  ├ chunks/fd9d1056-51920e345d2966e8.js  53.4 kB
  └ other shared chunks (total)          1.98 kB

Write logs to Cloud Logging

If you want to log custom events, you can write to Cloud Logging from Cloud Run, where your server-rendered code runs. Use standard JavaScript logging calls such as console.log and console.error. For example, to write a custom entry from code for a Next.js route handler, you would do something like this:

  • console.log() commands have the INFO log level.
  • console.info() commands have the INFO log level.
  • console.warn() commands have the ERROR log level.
  • console.error() commands have the ERROR log level.
  • Internal system messages have the DEBUG log level.

Note that console.log pipes through to Cloud Logging in the server-rendered code for your app. Events related to static rendering are sent to Cloud Build logs, while server rendering are sent to Cloud Run logs.

View metrics in the console

From the Firebase console, you can access traffic and utilization metrics for the Cloud Run service powering your Web app.

From the Firebase console context menu (a 3-dot menu at upper right) for the current rollout, select View Cloud Run metrics. You'll be able to monitor the number of requests reaching your Cloud Run service, including the breakdown by response code to understand your app's error rate.

You'll also find request latency and container utilization metrics (such as CPU utilization and Memory utilization), to understand your app's performance and scalability.

View server errors

Cloud Error Reporting consolidates errors from your App Hosting Cloud Run instance. You can optionally configure Cloud Error Reporting to notify you when new errors arise.