问题描述
此配置有效,但是我想要的是动态地给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 (将#修改为@)