[英]Nlog Posting to a CosmosDB Target
我正在使用Nlog并尝试使用https://www.nuget.org/packages/Nlog.DocumentDBTarget/将其发布到CosmosDB(DocumentDB)目标
我的配置代码如下所示
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的文档我没有找到任何关于使用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"
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.