NLog MSMQ Target for writing to Microsoft Message Queue (MSMQ)
-
Install the package
Install-Package NLog.MSMQ
or in your csproj:<PackageReference Include="NLog.MSMQ" Version="5.*" />
-
Add to your nlog.config:
<extensions> <add assembly="NLog.MSMQ"/> </extensions>
Alternative register from code using fluent configuration API:
LogManager.Setup().SetupExtensions(ext => { ext.RegisterTarget<NLog.Targets.MessageQueueTarget>(); });
Example of using the target "MSMQ" in nlog.config
-file:
<nlog>
<extensions>
<add assembly="NLog.MSMQ"/>
</extensions>
<targets>
<target name="msmq" xsi:type="MSMQ" layout="${message}" />
</targets>
<rules>
<logger minLevel="Info" writeTo="msmq" />
</rules>
</nlog>