Nlog 发布到 CosmosDB 目标
Nlog Posting to a CosmosDB Target
我正在使用 Nlog 并尝试将其 post 设为 CosmosDB(DocumentDB) 目标
使用 https://www.nuget.org/packages/Nlog.DocumentDBTarget/
我的配置代码是这样的
var documentDBTarget = new DocumentDBTarget()
{
Name = "logDocument",
EndPoint = "https://[my endpoint].documents.azure.com:443/",
AuthorizationKey = "[my auth key]",
Collection = "[my collection]",
Database = "[my database]",
Layout=jsonLayout
};
config.AddTarget(documentDBTarget);
config.AddRuleForAllLevels(documentDBTarget);
我已经声明了 jsonLayout,然后我配置了记录器并使用它开始记录。当我登录到本地文件目标或控制台目标时,这工作正常,但它不适用于 cosmosDB
LogManager.Configuration =config;
Logger logger = LogManager.GetLogger("Example");
logger.Info("{object}");
我错过了什么? https://github.com/goto10hq/NLog.DocumentDB?files=1 的文档
我没有找到任何关于 posting 使用 Nlog 的信息我只找到了关于配置它的信息我相信我做对了
谢谢
在我的电脑上工作。您尝试记录的对象是否与 JSON 布局一致?
var jsonLayout = new JsonLayout()
{
Attributes =
{
new JsonAttribute("name", "${name}"),
new JsonAttribute("level", "${level}"),
new JsonAttribute("message", "${message}"),
}
};
…
logger.Info(new
{
Name = "SomeName",
Level = "SomeLevel",
Message = "HelloWorld"
});
我正在使用 Nlog 并尝试将其 post 设为 CosmosDB(DocumentDB) 目标 使用 https://www.nuget.org/packages/Nlog.DocumentDBTarget/
我的配置代码是这样的
var documentDBTarget = new DocumentDBTarget()
{
Name = "logDocument",
EndPoint = "https://[my endpoint].documents.azure.com:443/",
AuthorizationKey = "[my auth key]",
Collection = "[my collection]",
Database = "[my database]",
Layout=jsonLayout
};
config.AddTarget(documentDBTarget);
config.AddRuleForAllLevels(documentDBTarget);
我已经声明了 jsonLayout,然后我配置了记录器并使用它开始记录。当我登录到本地文件目标或控制台目标时,这工作正常,但它不适用于 cosmosDB
LogManager.Configuration =config;
Logger logger = LogManager.GetLogger("Example");
logger.Info("{object}");
我错过了什么? https://github.com/goto10hq/NLog.DocumentDB?files=1 的文档 我没有找到任何关于 posting 使用 Nlog 的信息我只找到了关于配置它的信息我相信我做对了
谢谢
在我的电脑上工作。您尝试记录的对象是否与 JSON 布局一致?
var jsonLayout = new JsonLayout()
{
Attributes =
{
new JsonAttribute("name", "${name}"),
new JsonAttribute("level", "${level}"),
new JsonAttribute("message", "${message}"),
}
};
…
logger.Info(new
{
Name = "SomeName",
Level = "SomeLevel",
Message = "HelloWorld"
});