用于使用存储过程的DocumentDB API采用一个可选的RequestOptions参数,除其他外,该参数具有属性EnableScriptLogging。
它的帮助页是无用的。它的描述是:
EnableScriptLogging用于在JavaScript存储过程中启用/禁用日志记录。
麦凯..。那么,,我如何记录一些东西?(假设这是console.log(...)),更重要的是,如何读取由存储过程生成的日志( logs )中的?
我原以为请求到存储过程的response会以某种方式包含日志,但什么也找不到。
发布于 2017-06-19 21:58:34
是的,这是脚本中的console.log。必须由客户端启用(默认情况下关闭,以便忽略脚本中的console.log ),本质上是根据请求设置http-头。
在脚本中,您可以这样做:
function myScript() {
console.log("This is trace log");
}日志将在响应头(x documentdb-script- log -结果)中,也可以在SDK中访问。
如果使用C# SDK,您可以这样使用它:
var options = new RequestOptions { EnableScriptLogging = true };
var response = await client.ExecuteStoredProcedureAsync<string>(sprocUri, options);
Console.WriteLine(response.ScriptLog);如果您使用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]);
}目前的限制:
https://stackoverflow.com/questions/44610233
复制相似问题