自上次部署以来,我的应用开始出现一些奇怪的日志记录错误。
File "/env/lib/python3.6/site-packages/google/cloud/logging/handlers/transports/background_thread.py", line 118, in _safely_commit_batch
batch.commit()
File "/env/lib/python3.6/site-packages/google/cloud/logging/logger.py", line 612, in commit
client.logging_api.write_entries(entries, **kwargs)
File "/env/lib/python3.6/site-packages/google/cloud/logging/_gapic.py", line 124, in write_entries
partial_success=partial_success)
File "/env/lib/python3.6/site-packages/google/cloud/logging_v2/gapic/logging_service_v2_client.py", line 341, in write_log_entries
request, retry=retry, timeout=timeout, metadata=metadata)
File "/env/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py", line 139, in __call__
return wrapped_func(*args, **kwargs)
File "/env/lib/python3.6/site-packages/google/api_core/retry.py", line 260, in retry_wrapped_func
on_error=on_error,
File "/env/lib/python3.6/site-packages/google/api_core/retry.py", line 177, in retry_target
return target()
File "/env/lib/python3.6/site-packages/google/api_core/timeout.py", line 206, in func_with_timeout
return func(*args, **kwargs)
File "/env/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 61, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission
"
timestamp: "2018-09-19T21:35:58Z"
}
但是,如果我运行本地服务器,则一切正常。
我尝试在本地安装最新的日志库,并测试了可以在本地环境中发送日志。有办法调试吗?
答案 0 :(得分:2)
您可能要检查已部署的App Engine应用程序使用的服务帐户是否拥有必要的日志记录权限。除非您已更改,否则通常是一个服务帐户,例如PROJECT_ID@appspot.gserviceaccount.com。
您可以在“开发者控制台”>“ IAM和管理”部分中将日志记录>“日志编写者”角色添加到该服务帐户。