【发布时间】:2011-10-26 00:52:59
【问题描述】:
尝试使用 NLog 从我们的 C# 应用程序中发送 JSON 编码的日志,将它们转储到 CouchDB 中。但是,使用 Network 目标,我似乎找不到正确设置 Content-Type 标头的方法;否则 CouchDB 与我的输入无关。
CouchDB 开箱即用,当前 NLog 配置:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
<variable name="FileLayout" value='{ "date":"${longdate}","level":"${level}","message":${message}}' />
<targets>
<target name="logfile" xsi:type="Network" address="http://127.0.0.1:5984/logger/" layout="${FileLayout}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="logfile" />
</rules>
</nlog>
以及原始 HTTP(已编辑主机名):
POST http://127.0.0.1:5984/logger/ HTTP/1.1
Host: 127.0.0.1:5984
Content-Length: 221
Expect: 100-continue
{ "date":"2011-08-12 13:38:06.4603","level":"Info","message":{"backlog":0, "too_busy":0, "io_threads":1000, "threads":32766, "messages_processed":0}, "ProcessName": "foobar"}
【问题讨论】:
-
请发布您在应用程序和 CoucheDb 的代码和配置方面的内容
标签: c# json logging couchdb nlog