如何解决我想在nlog mongo配置中将集合名称作为变量
此配置有效,但是我想要的是动态地给databaseName =“ logDb”。因此,我希望在应用程序运行时更改“ logDb”值。
此nlog mongodb配置:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true">
<extensions>
<add assembly="NLog.Mongo" />
</extensions>
<targets async="true">
<target xsi:type="Mongo"
name="mongoCustom"
includeDefaults="false"
connectionString="mongodb://mongodb0.example.com:27017"
databaseName="logDb"
collectionName="DefaultLogDocument"
cappedCollectionSize="26214400">
<field name="Date" layout="${longdate}" bsonType="DateTime" />
<field name="Level" layout="${level}"/>
<field name="Message" layout="${message}" />
<field name="Logger" layout="${logger}"/>
<field name="Location" layout="${callsite:className=true:methodName=true}" />
<field name="Exception" layout="${exception:format=tostring}" />
<field name="ThreadId" layout="${threadid}" bsonType="Int32" />
<field name="ThreadName" layout="${threadname}" />
<field name="ProcessId" layout="${processid}" bsonType="Int32" />
<field name="ProcessName" layout="${processname:fullName=true}" />
</target>
</targets>
<rules>
<!--Rules Section-->
<logger name="*" minlevel="Warn" writeTo="mongoCustom" />
</rules>
</nlog>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。