-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MSMQ target
Writes log messages to the Microsoft Message Queue (MSMQ).
Platforms Supported: Limited - Windows only as it depends on mqrt.dll, and requires nuget-package NLog.MSMQ
<targets>
<target xsi:type="MSMQ"
name="String"
useXmlEncoding="Boolean"
encoding="Encoding"
layout="Layout"
recoverable="Boolean"
createQueueIfNotExists="Boolean"
checkIfQueueExists="Boolean"
label="Layout"
queue="Layout" />
</targets>
Read more about using the Configuration File.
-
name - Name of the target.
-
useXmlEncoding - Indicates whether to use the XML format when serializing message. Boolean Default: False
-
encoding - Encoding to be used when writing text to the queue. Encoding
-
layout - Layout used to format log messages. Layout Required. Default:
${longdate}|${level:uppercase=true}|${logger}|${message:withException=true}
Queue Options:
-
queue - Name of the queue to write to. Layout Required.
To write to a private queue on a local machine use .\private$\QueueName. For other available queue names, consult MSMQ documentation. -
label - Label to associate with each message. Layout Default: ""
Changed default value from
"NLog"
to""
with NLog.MSMQ ver. 5.3 -
recoverable - Indicates whether to use recoverable messages (with guaranteed delivery). Boolean Default: False
-
singleTransaction - Indicates whether to send single-transaction-style to transactional queue. Boolean Default: False
Introduced with NLog.MSMQ ver. 5.3
-
checkIfQueueExists - If true then it will check if queue exists for every message sent, which can be useful if troubleshooting. The queue exist check might cause Exception to be thrown when private-remote-queue, and prevent message send. Boolean Default: False
Changed default value from
true
tofalse
with NLog.MSMQ ver. 5.3 -
createQueueIfNotExists - Indicates whether to create the queue if it doesn't exists. Notice this means it will check if queue exists for every message sent. Boolean Default: False
The MSMQ target requires that:
- Installing Nuget-package NLog.MSMQ (Before NLog 5.0 it was NLog.Extended)
- The machine doing the logging have MSMQ installed with the Active Directory Domain Services Integration option. If the option is not installed, the target will throw an exception.
- The queue being written to is NOT transactional.
Introduced
SingleTransaction
with NLog.MSMQ ver. 5.3, that should support transactional queues.
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json