NLog schema, XSD won't work for new FilteringWrapper syntax
related https://github.com/NLog/NLog/issues/3472
after fix, then:
works (no XSD errors):
<target xsi:type="FilteringWrapper" name="default" >
<filter xsi:type="whenRepeated" layout="${message}" timeoutSeconds="30" action="Ignore" />
<filter xsi:type="when"/>
</target>
works:
<target xsi:type="FilteringWrapper" name="default" >
<target xsi:type="Console" />
</target>
not working
<target xsi:type="FilteringWrapper" name="default" >
<filter xsi:type="whenRepeated" layout="${message}" timeoutSeconds="30" action="Ignore" />
<filter xsi:type="when"/>
<target xsi:type="Console" />
</target>
he element 'target' in namespace 'http://www.nlog-project.org/schemas/NLog.xsd' has invalid child element 'target' in namespace 'http://www.nlog-project.org/schemas/NLog.xsd'. List of possible elements expected: 'name, condition, filter, optimizeBufferReuse' in namespace 'http://www.nlog-project.org/schemas/NLog.xsd'.
The issue is that in the XSD, it's a "choice":
<xs:complexType name="FilteringWrapper">
<xs:complexContent>
<xs:extension base="WrapperTargetBase">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
<xs:element name="condition" minOccurs="0" maxOccurs="1" type="Condition" />
<xs:element name="filter" minOccurs="0" maxOccurs="1" type="Filter" />
<xs:element name="optimizeBufferReuse" minOccurs="0" maxOccurs="1" type="xs:boolean" />
</xs:choice>
There is only support for one filter. So one cannot have two <filter>-elements:
<target xsi:type="FilteringWrapper" name="default" >
<filter xsi:type="whenRepeated" layout="${message}" timeoutSeconds="30" action="Ignore" />
<filter xsi:type="when"/>
Strange that it doesn't inherit <target>-item from WrapperTargetBase
Strange that it doesn't inherit
-item from WrapperTargetBase
It does! But combining target + condition gives a xsd error
There is only support for one filter
Would be nice to fix that also. Anyway, needs docs on wiki I guess (or I missed that)
There is only support for one filter
Would be nice to fix that also.
There is already: https://github.com/NLog/NLog/wiki/PostFilteringWrapper-target (For those with crazy desires for very advanced filtering)
Not super skilled with MakeNLogXSD. But maybe this will improve the output: #3474
note:
to fix (disallow it 2nd filter)
<target xsi:type="FilteringWrapper" name="default" >
<filter xsi:type="whenRepeated" layout="${message}" timeoutSeconds="30" action="Ignore" />
<filter xsi:type="when"/>
</target>
we need:
<xs:complexType name="FilteringWrapper">
<xs:complexContent>
<xs:extension base="WrapperTargetBase">
<xs:choice minOccurs="0" maxOccurs="1"> <!-- maxOccurs changed to 1, was unbounded -->
<xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
<xs:element name="condition" minOccurs="0" maxOccurs="1" type="Condition" />
<xs:element name="filter" minOccurs="0" maxOccurs="1" type="Filter" />
<xs:element name="optimizeBufferReuse" minOccurs="0" maxOccurs="1" type="xs:boolean" />
</xs:choice>
but I'am afraid this won't count for all elements.
Also those elements as "optimizeBufferReuse" are a bit strange (those are also as attribute) - not sure if that's correct
note, this works:
<target xsi:type="FilteringWrapper" name="default" >
<target xsi:type="Console" />
<filter xsi:type="whenRepeated" layout="${message}" timeoutSeconds="30" action="Ignore" />
</target>
first target, then filter.