首页 > 解决方案 > Google Drive API Java 客户端库日志记录

问题描述

Google Drive API Java 客户端是否记录传出 REST - HTTP 请求和传入 REST - HTTP 响应?

这对于调试 API 调用以确保处理正确的请求和响应非常重要。

有没有办法打开日志记录以查看通过 DRIVE API 调用发送给 Google 的请求和响应?

谢谢

标签: javagoogle-apigoogle-drive-apigoogle-api-java-client

解决方案


它使用 java.util.logging.Logger 记录 HTTP 请求和响应详细信息,包括 URL、标头和内容。

通常使用 logging.properties 文件管理日志记录。例如:

# Properties file which configures the operation of the JDK logging facility.
# The system will look for this config file to be specified as a system property:
# -Djava.util.logging.config.file=${project_loc:googleplus-simple-cmdline-sample}/logging.properties

# Set up the console handler (uncomment "level" to show more fine-grained messages)
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = CONFIG

# Set up logging of HTTP requests and responses (uncomment "level" to show)
com.google.api.client.http.level = CONFIG

有关更多信息,请参阅日志记录


推荐阅读