DocumentDB存储的Procs:EnableScriptLogging选项有什么作用? [英] DocumentDB Stored Procs: what does the EnableScriptLogging option do?

查看:55
本文介绍了DocumentDB存储的Procs:EnableScriptLogging选项有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于存储过程的DocumentDB API带有一个可选的RequestOptions参数,该参数除其他外具有属性EnableScriptLogging.

The DocumentDB APIs for working with stored procedures take an optional RequestOptions argument that has, among others, the property EnableScriptLogging.

帮助页面,因为它是没有用的.的描述是:

The help page for it is useless. The description for it is:

EnableScriptLogging用于启用/禁用JavaScript存储过程中的日志记录.

EnableScriptLogging is used to enable/disable logging in JavaScript stored procedures.

好吧...所以我该如何记录? (假设是console.log(...)) 更重要的是,如何读取由存储过程生成的日志?

Mkay... so how do I log something? (assuming that's console.log(...)) And more importantly, how do I read the logs generated by stored procedures?

我期望对存储过程的请求的response将以某种方式包含日志,但找不到任何内容.

I was expecting the response of requests to stored procedures would somehow contain the logs, but can't find anything.

推荐答案

是的,这是针对脚本中的console.log的.必须由客户端启用(默认情况下处于关闭状态,因此脚本中的console.log会被忽略),实际上这是根据请求设置的HTTP标头.
在脚本中,您可以执行以下操作:

Yes, this is for console.log from script. Must be enabled by client (turned off by default, so that console.log in script is ignored), essentially this set http-header on request.
In script you can do something like this:

function myScript() { 
  console.log("This is trace log");
}

该日志将显示在响应标头(x-ms-documentdb-script-log-results)中,并且可以在SDK中进行访问.

如果您使用C#SDK,则可以像这样使用它:

The log will be in response header (x-ms-documentdb-script-log-results), as well as can be accessible in SDK.

If you use C# SDK, you can use it like this:

var options = new RequestOptions { EnableScriptLogging = true };
var response = await client.ExecuteStoredProcedureAsync<string>(sprocUri, options);
Console.WriteLine(response.ScriptLog);

如果使用node.js SDK:

If you use node.js SDK:

var lib = require("documentdb");
var Client = lib.DocumentClient;
var client = new Client("https://xxxxxxx.documents.azure.com:443/", { masterKey: "xxxxxxxxxxxx" });
var sprocLink = ...;
client.executeStoredProcedure(sprocLink, "input params", { partitionKey: {}, enableScriptLogging: true }, function(err, res, responseHeaders) {
console.log(responseHeaders[lib.Constants.HttpHeaders.ScriptLogResults]);
}

当前限制:

  • 仅对存储过程启用
  • \ n不支持(应尽快修复)
  • 脚本抛出未处理的异常时不支持(应尽快修复)

这篇关于DocumentDB存储的Procs:EnableScriptLogging选项有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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