Documentation says:
Sometimes we require ALL targets to be wrapped in the same way, for example to add buffering and/or retrying. NLog provides
<default-wrapper />
syntax for that. You simply put this element in the<targets />
section and all your targets will be automatically wrapped with the specified wrapper.
It also provides the following example:
<nlog>
<targets>
<default-wrapper xsi:type="BufferingWrapper" bufferSize="100"/>
<target name="f1" xsi:type="File" fileName="f1.txt"/>
<target name="f2" xsi:type="File" fileName="f2.txt"/>
</targets>
<targets>
<default-wrapper xsi:type="AsyncWrapper">
<wrapper-target xsi:type="RetryingWrapper"/>
</default-wrapper>
<target name="n1" xsi:type="Network" address="tcp://localhost:4001"/>
<target name="n2" xsi:type="Network" address="tcp://localhost:4002"/>
<target name="n3" xsi:type="Network" address="tcp://localhost:4003"/>
</targets>
</nlog>
So, <default-wrapper />
element should be a child of <targets>
to be applied to each <target>
within the same parent.
On the other hand, Extended Json NLog Config Example uses default-wrapper
on the same level as targets
element:
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Block"
},
"targets": {
So, I have the following questions:
targets
element be wrapped with the default-wrapper
, placed out of the targets
?default-wrapper
within targets
and default-wrapper
out of targets
in the same configuration file?Yes there was some discussion about whether XML-config and JSON-config should be completely 1-to-1. See also: https://github.com/NLog/NLog.Extensions.Logging/pull/283
Because JSON-config represented targets-section as a dictionary of known target-names, then it didn't feel natural to have default-wrapper
and default-target-parameters
as reserved magic-strings.
default-wrapper
.default-wrapper
and default-target-parameters
inside the targets-section-dictionary. Maybe check the NLog InternalLogger whether it complains about unknown configuration-items.Notice more work is being done to give default-wrapper
and default-target-parameters
a better name, since it might not be easy to guess that they both apply to the targets-section. See also: https://github.com/NLog/NLog.Extensions.Logging/pull/500