如何使用Azure存储客户端库(版本12)为Java启用客户端日志记录

时间:2020-04-25 07:27:28

标签: azure-blob-storage

我想使用Java sdk(ver12的Azure blob存储在客户端站点上记录请求/响应。

在Microsoft在线文档[https://docs.microsoft.com/en-us/rest/api/storageservices/client-side-logging-with-the-microsoft-azure-storage-sdk-for-java]中,我找到了此示例代码。

// Set logging off by default.  
OperationContext.setLoggingEnabledByDefault(false);  
OperationContext ctx = new OperationContext();  
ctx.setLoggingEnabled(true);  

// Create an operation to add a new customer to the people table.  
TableOperation insertCustomer1 = TableOperation.insertOrReplace(customer1);  

// Submit the operation to the table service.  
table.execute(insertCustomer1, null, ctx);  

但是它不起作用。 OperationContext在库中找不到。也许是较旧版本的示例。

我希望有人可以给我一个示例代码,谢谢。

1 个答案:

答案 0 :(得分:0)

OperationContextcom.microsoft.azure.storage的类,而最新版本是8.6.3

您可以在Java的Microsoft Azure存储SDK v8中获得OperationContext

如果您想访问我们的latest Java SDK,请参考下表中的Storage SDK v12 for Java链接。如果您想了解有关我们决定升级Java SDK和前进道路的更多信息,请参阅this document。如果您希望获得有关Azure在协调跨服务的SDK的开发方面迅速开展的工作的更多信息(此更改是其中的一部分),请参阅本文。