로깅과 측정항목은 코드 디버깅 및 모니터링을 하는 데 중요한 수단입니다.
App Hosting를 사용하면 웹 앱을 지원하는 Google Cloud 서비스(Cloud Run, Cloud Build, Cloud CDN)의 로그와 측정항목을 빠르게 확인할 수 있습니다.
Node.js의 console.log와 같은 표준 로깅 구문을 사용하여 Cloud Logging에 로그 항목을 작성할 수 있습니다.
콘솔에서 사용량 보기
각 백엔드에는 지난 7일 동안의 앱 트래픽(요청 수) 및 오류율 요약이 포함된 개요 탭이 있습니다.
각 백엔드에는 앱의 활동 및 사용량에 관한 여러 사용량 그래프가 있는 사용량 탭도 있습니다. 표시되는 데이터에는 CDN 대역폭 및 요청, Cloud Run CPU 및 메모리 사용률 등이 포함됩니다.
Google Cloud 콘솔에서 Cloud Run의 추가 사용률 측정항목 (예: CPU 사용률 및 메모리 사용률)을 확인할 수 있습니다.
콘솔에서 로그 보기
출시의 Firebase 콘솔 컨텍스트 메뉴 (오른쪽 상단의 점 3개 메뉴)에서 Cloud Run 수정사항 세부정보와 오류, 빌드 로그를 빠르게 볼 수 있습니다.
이 로그에는 App Hosting 배포를 디버깅하는 데 유용한 정보가 포함되어 있습니다. 예를 들어 Cloud Run 로그는 package.json를 찾을 수 없는 경우를 기록합니다.
빌드 로그에는 빌드 출력이 표시되므로 프레임워크의 구성에 오류가 발생했는지 아니면 App Hosting 구성에 오류가 발생했는지 분류할 수 있습니다. 또한 기본 runConfig 설정을 표시하고 설정이 누락되었거나 apphosting.yaml가 없는 경우를 나타냅니다.
> 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
Cloud Logging에 로그 작성
커스텀 이벤트를 로깅하려면 서버 측 렌더링 코드가 실행되는 Cloud Run에서 Cloud Logging에 쓰면 됩니다. console.log, console.error와 같은 표준 JavaScript 로깅 호출을 사용합니다. 예를 들어 Next.js 경로 핸들러의 코드에서 맞춤 항목을 작성하려면 다음과 같이 하면 됩니다.
console.log() 명령어의 로그 수준은 정보입니다.
console.info() 명령어의 로그 수준은 정보입니다.
console.warn() 명령어의 로그 수준은 오류입니다.
console.error() 명령어의 로그 수준은 오류입니다.
내부 시스템 메시지의 로그 수준은 디버그입니다.
console.log는 앱의 서버 측 렌더링 코드에서 Cloud Logging로 파이프됩니다. 정적 렌더링과 관련된 이벤트는 Cloud Build 로그로 전송되고 서버 측 렌더링은 Cloud Run 로그로 전송됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-06(UTC)"],[],[],null,["\u003cbr /\u003e\n\nLogging and metrics are important tools for debugging and monitoring code.\nApp Hosting provides quick access to view logs and metrics for the Google\nCloud services powering your web app:\nCloud Run, Cloud Build and Cloud CDN.\n\nUsing standard logging syntax like Node.js' `console.log`, you can write log\nentries to Cloud Logging.\n\nView usage in the console\n\nEach backend has an **Overview** tab, with a summary of your app's traffic\n(request count) and error rate over the past seven days.\n\nEach backend also has a **Usage** tab with several usage\ngraphs for activity and usage of your app. The data represented includes CDN\nbandwidth and requests, Cloud Run CPU and memory utilization, and more.\n\nYou can find additional utilization metrics for Cloud Run (such as CPU\nutilization and Memory utilization), in the Google Cloud console.\n\nView logs in the console\n\nFrom the Firebase console context menu (a 3-dot menu at upper right) for a\nrollout, you can get quick access to view the Cloud Run revision\ndetails and errors as well as build logs.\n\nThese logs contain helpful information for debugging your App Hosting\ndeployments. For example, the Cloud Run log notes when `package.json`\nis not found.\n\nThe build log displays your build output, allowing you to triage\nwhether errors occurred in configuration in your framework, or in\nApp Hosting configuration. It also displays your basic `runConfig` settings,\nand indicates when settings are missing or when `apphosting.yaml` does not\nexist: \n\n \u003e next build\n\n ▲ Next.js 14.1.4\n - Environments: .env\n\n ...\n\n Route (app) Size First Load JS\n ┌ λ / 4.79 kB 214 kB\n ├ λ /_not-found 882 B 85.3 kB\n └ λ /restaurant/[id] 5.28 kB 207 kB\n + First Load JS shared by all 84.4 kB\n ├ chunks/69-6678c81190a8fe82.js 29 kB\n ├ chunks/fd9d1056-51920e345d2966e8.js 53.4 kB\n └ other shared chunks (total) 1.98 kB\n\nWrite logs to Cloud Logging\n\nIf you want to log custom events, you can write to Cloud Logging from\nCloud Run, where your server-rendered code runs. Use standard\nJavaScript logging calls such as `console.log` and `console.error`. For example,\nto write a custom entry from code for a\n[Next.js route handler](https://www.google.com/url?q=https://nextjs.org/docs/app/building-your-application/routing/route-handlers),\nyou would do something like this:\n\n- `console.log()` commands have the **INFO** log level.\n- `console.info()` commands have the **INFO** log level.\n- `console.warn()` commands have the **ERROR** log level.\n- `console.error()` commands have the **ERROR** log level.\n- Internal system messages have the **DEBUG** log level.\n\nNote that `console.log` pipes through to Cloud Logging in the\n*server-rendered* code for your app. Events related to static rendering are sent\nto Cloud Build logs, while server rendering are sent to Cloud Run\nlogs.\n\nView server errors\n\n[Cloud Error Reporting](https://www.google.com/url?q=https://cloud.google.com/error-reporting/docs/grouping-errors)\nconsolidates errors from your App Hosting Cloud Run instance.\nYou can optionally configure\nCloud Error Reporting to\n[notify you when new errors arise](https://cloud.google.com/error-reporting/docs/notifications)."]]