小编acp*_*acp的帖子

让NLog发送带有正确标头的JSON?

尝试使用NLog从我们的C#app发送JSON编码的日志,将它们转储到CouchDB中.但是,使用网络目标,我似乎无法找到正确设置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>
Run Code Online (Sandbox Code Playgroud)

并且原始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"}
Run Code Online (Sandbox Code Playgroud)

c# logging json couchdb nlog

8
推荐指数
1
解决办法
3420
查看次数

标签 统计

c# ×1

couchdb ×1

json ×1

logging ×1

nlog ×1