Microsoft Azure CosmostDB Script Explorer console.log

孤街醉人 提交于 2019-12-11 05:27:11

问题


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.

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

thanks.


回答1:


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

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

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();
}

Output:

Please note that this code is necessary to print console.log:

options.setScriptLoggingEnabled(true);



来源:https://stackoverflow.com/questions/45742082/microsoft-azure-cosmostdb-script-explorer-console-log

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!