我正在尝试将RavenDB 3.0日志消息放入Seq。
Seq支持使用JSON发布原始事件:http://docs.getseq.net/docs/posting-raw-events
RavenDB使用NLog进行日志记录。 NLog支持WebService目标:https://github.com/NLog/NLog/wiki/WebService-target
到目前为止,我的尝试是:
<target type='WebService'
name='Seq'
url='http://localhost:5341/api/events/raw'
protocol='JsonPost'
encoding='UTF-8'>
<layout xsi:type="JsonLayout">
<attribute name='@t' layout="${longdate}" >
<attribute name='@mt' layout="${message}" >
</layout>
</target>
完整的NLog.config文件是:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.netfx35.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target
xsi:type="AsyncWrapper"
name="AsyncLog">
<target xsi:type="SplitGroup">
<!-- create log files with a max size of 256 MB -->
<target
name="File"
xsi:type="File"
archiveAboveSize="268435456"
fileName="${basedir}\Logs\${shortdate}.log">
<layout xsi:type="CsvLayout">
<column name="time" layout="${longdate}" />
<column name="logger" layout="${logger}"/>
<column name="level" layout="${level}"/>
<column name="database" layout="${mdc:item=database}"/>
<column name="threadid" layout="${threadid}" />
<column name="message" layout="${message}" />
<column name="exception" layout="${exception:format=tostring}" />
</layout>
</target>
<target type='WebService'
name='Seq'
url='http://localhost:5341/api/events/raw'
protocol='JsonPost'
encoding='UTF-8'>
<layout xsi:type="JsonLayout">
<attribute name='@t' layout="${longdate}" >
<attribute name='@mt' layout="${message}" >
</layout>
</target>
</target>
</target>
<target
xsi:type="AsyncWrapper"
name="AsyncConflictLog">
<target xsi:type="SplitGroup">
<!-- create log files with a max size of 256 MB -->
<target
name="File"
xsi:type="File"
archiveAboveSize="268435456"
fileName="${basedir}\Logs\${shortdate}.conflicts.log">
<layout xsi:type="CsvLayout">
<column name="time" layout="${longdate}" />
<column name="logger" layout="${logger}"/>
<column name="level" layout="${level}"/>
<column name="database" layout="${mdc:item=database}"/>
<column name="threadid" layout="${threadid}" />
<column name="message" layout="${message}" />
<column name="exception" layout="${exception:format=tostring}" />
</layout>
</target>
</target>
</target>
</targets>
<rules>
<!--<logger name="Raven.Bundles.Replication.Plugins.*" writeTo="AsyncConflictLog" minlevel="Debug"/>-->
<logger name="Raven.*" writeTo="AsyncLog" minlevel="Trace"/>
</rules>
</nlog>
我在运行时遇到问题 - 我认为我的布局无效但我没有从RavenDB / NLog中得到任何错误,因此很难找出它不喜欢的内容。
有没有人这样做过,或者你能看出可能出现的问题吗?