[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Logging\n\nKf provides you with several types of logs. This document describes these logs and how to access them.\n\nApplication logs\n----------------\n\nAll logs written to standard output `stdout` and standard error `stderr`, are uploaded to [Cloud Logging](/logging) and stored under the log name `user-container`.\n\nOpen [Cloud Logging](/logging/docs/view/logs-explorer-interface) and run the following query: \n\n```\nresource.type=\"k8s_container\"\nlog_name=\"projects/YOUR_PROJECT_ID/logs/user-container\"\nresource.labels.project_id=YOUR_PROJECT_ID\nresource.labels.location=GCP_COMPUTE_ZONE (e.g. us-central1-a)\nresource.labels.cluster_name=YOUR_CLUSTER_NAME\nresource.labels.namespace_name=YOUR_KF_SPACE_NAME\nresource.labels.pod_name:YOUR_KF_APP_NAME\n```\n\n\u003cbr /\u003e\n\nYou should see all your application logs written on standard `stdout` and standard error `stderr`.\n\nAccess logs for your applications\n---------------------------------\n\nKf provides access logs using [Istio sidecar injection](/service-mesh/docs/proxy-injection). Access logs are stored under the log name `server-accesslog-stackdriver`.\n\nOpen [Cloud Logging](/logging/docs/view/logs-explorer-interface) and run the following query: \n\n```\nresource.type=\"k8s_container\"\nlog_name=\"projects/YOUR_PROJECT_ID/logs/server-accesslog-stackdriver\"\nresource.labels.project_id=YOUR_PROJECT_ID\nresource.labels.location=GCP_COMPUTE_ZONE (e.g. us-central1-a)\nresource.labels.cluster_name=YOUR_CLUSTER_NAME\nresource.labels.namespace_name=YOUR_KF_SPACE_NAME\nresource.labels.pod_name:YOUR_KF_APP_NAME\n```\n\n\u003cbr /\u003e\n\nYou should see access logs for your application. Sample access log: \n\n```\n{\n \"insertId\": \"166tsrsg273q5mf\",\n \"httpRequest\": {\n \"requestMethod\": \"GET\",\n \"requestUrl\": \"http://test-app-38n6dgwh9kx7h-c72edc13nkcm.***. ***.nip.io/\",\n \"requestSize\": \"738\",\n \"status\": 200,\n \"responseSize\": \"3353\",\n \"remoteIp\": \"10.128.0.54:0\",\n \"serverIp\": \"10.48.0.18:8080\",\n \"latency\": \"0.000723777s\",\n \"protocol\": \"http\"\n },\n \"resource\": {\n \"type\": \"k8s_container\",\n \"labels\": {\n \"container_name\": \"user-container\",\n \"project_id\": ***,\n \"namespace_name\": ***,\n \"pod_name\": \"test-app-85888b9796-bqg7b\",\n \"location\": \"us-central1-a\",\n \"cluster_name\": ***\n }\n },\n \"timestamp\": \"2020-11-19T20:09:21.721815Z\",\n \"severity\": \"INFO\",\n \"labels\": {\n \"source_canonical_service\": \"istio-ingressgateway\",\n \"source_principal\": \"spiffe://***.svc.id.goog/ns/istio-system/sa/istio-ingressgateway-service-account\",\n \"request_id\": \"0e3bac08-ab68-408f-9b14-0aec671845bf\",\n \"source_app\": \"istio-ingressgateway\",\n \"response_flag\": \"-\",\n \"route_name\": \"default\",\n \"upstream_cluster\": \"inbound|80|http-user-port|test-app.***.svc.cluster.local\",\n \"destination_name\": \"test-app-85888b9796-bqg7b\",\n \"destination_canonical_revision\": \"latest\",\n \"destination_principal\": \"spiffe://***.svc.id.goog/ns/***/sa/sa-test-app\",\n \"connection_id\": \"82261\",\n \"destination_workload\": \"test-app\",\n \"destination_namespace\": ***,\n \"destination_canonical_service\": \"test-app\",\n \"upstream_host\": \"127.0.0.1:8080\",\n \"log_sampled\": \"false\",\n \"mesh_uid\": \"proj-228179605852\",\n \"source_namespace\": \"istio-system\",\n \"requested_server_name\": \"outbound_.80_._.test-app.***.svc.cluster.local\",\n \"source_canonical_revision\": \"asm-173-6\",\n \"x-envoy-original-dst-host\": \"\",\n \"destination_service_host\": \"test-app.***.svc.cluster.local\",\n \"source_name\": \"istio-ingressgateway-5469f77856-4n2pw\",\n \"source_workload\": \"istio-ingressgateway\",\n \"x-envoy-original-path\": \"\",\n \"service_authentication_policy\": \"MUTUAL_TLS\",\n \"protocol\": \"http\"\n },\n \"logName\": \"projects/*/logs/server-accesslog-stackdriver\",\n \"receiveTimestamp\": \"2020-11-19T20:09:24.627065813Z\"\n}\n```\n\nAudit logs\n----------\n\n[Audit Logs](/kubernetes-engine/docs/how-to/audit-logging) provides a\nchronological record of calls that have been made to the Kubernetes API Server. Kubernetes audit log entries are useful for investigating suspicious API requests, for collecting statistics, or for creating monitoring alerts for unwanted API calls.\n\nOpen [Cloud Logging](/logging/docs/view/logs-explorer-interface) and run the following query: \n\n```\nresource.type=\"k8s_container\"\nlog_name=\"projects/YOUR_PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity\"\nresource.labels.project_id=YOUR_PROJECT_ID\nresource.labels.location=GCP_COMPUTE_ZONE (e.g. us-central1-a)\nresource.labels.cluster_name=YOUR_CLUSTER_NAME\nprotoPayload.request.metadata.name=YOUR_APP_NAME\nprotoPayload.methodName:\"deployments.\"\n```\n\n\u003cbr /\u003e\n\nYou should see a trace of calls being made to the Kubernetes API server.\n\nLogging Access control\n----------------------\n\nFollow the instructions [here](/logging/docs/access-control) to provide logs access to developers and other members on the team. The role `roles/logging.viewer` provides read-only access to logs.\n\nLogs Router\n-----------\n\nYou can also use [Logs Router](/logging/docs/routing/overview) to route the logs to supported destinations."]]