Microsoft Azure CosmostDB脚本资源管理器console.log [英] Microsoft Azure CosmostDB Script Explorer console.log

查看:87
本文介绍了Microsoft Azure CosmostDB脚本资源管理器console.log的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript调试存储过程或用Microsoft Azure CosmosDB'Script Explorer'编写的脚本.我放了几条console.log()消息,以便可以跟踪我的proc,而找不到这些日志消息的写入位置.

I am trying to debug a stored procedure or a script written in Microsoft Azure CosmosDB 'Script Explorer' using javascript. I put several console.log() messages so that I could trace my proc and I couldn't find where those log messages are written to.

在脚本框架上,有一个文本框用于输入输入变量,在其下方有一个文本框,用于显示响应.

On the script frame, there is a text box to enter your input variables and below that there is a text box which displays response.

在哪里可以找到使用console.log()记录的日志消息?

Where do I find the log messages that I log using console.log()?

谢谢.

推荐答案

我找到了一种 getScriptLog 方法来获取控制台. Azure Cosmos DB存储过程中的日志()语句官方文档.

I've found a getScriptLog method to get the console. Log () statement in the Azure Cosmos DB Stored Proceduce official documentation.

我在Azure Cosmos DB集合中创建了一个存储过程,如下所示:

I created a stored procudure in my Azure Cosmos DB Collection as below:

我不知道您当前使用的是哪种语言的SDK,请参考下面的 Java SDK 示例代码,也可以在其他SDK中实现.

I don't know what language SDK you are currently using, please refer to the Java SDK sample code as below which could also be implemented in other SDKs.

//query exist stored procedure in collection
StoredProcedure createdSproc =documentClient.readStoredProcedure("dbs/" + DATABASE_ID + "/colls/" + COLLECTION_ID +"/sprocs/"+"test", null).getResource();
//print query result
System.out.println(createdSproc.toString());
try {
    //set Request options
    RequestOptions options=new RequestOptions();
    //enable script logging  true
    options.setScriptLoggingEnabled(true);
    //execute stored procedure
    StoredProcedureResponse spr = documentClient.executeStoredProcedure(createdSproc.getSelfLink(), options,
            null);
    System.out.println(spr.toString());
    System.out.println("status code: "+spr.getStatusCode());
    //print script log
    System.out.println("Scrpit Log: "+ spr.getScriptLog());
    System.out.println("Response body: "+spr.getResponseAsString());
} catch (DocumentClientException e) {
    e.printStackTrace();
}

输出:

请注意,此代码对于打印console.log是必需的:

options.setScriptLoggingEnabled(true);

options.setScriptLoggingEnabled(true);

这篇关于Microsoft Azure CosmostDB脚本资源管理器console.log的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆