NLog icon indicating copy to clipboard operation
NLog copied to clipboard

NLog schema, XSD won't work for new FilteringWrapper syntax

Open 304NotModified opened this issue 6 years ago • 7 comments

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>

304NotModified avatar Jun 11 '19 21:06 304NotModified

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

snakefoot avatar Jun 11 '19 21:06 snakefoot

Strange that it doesn't inherit -item from WrapperTargetBase

It does! But combining target + condition gives a xsd error

304NotModified avatar Jun 11 '19 22:06 304NotModified

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)

304NotModified avatar Jun 11 '19 22:06 304NotModified

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)

snakefoot avatar Jun 11 '19 22:06 snakefoot

Not super skilled with MakeNLogXSD. But maybe this will improve the output: #3474

snakefoot avatar Jun 11 '19 23:06 snakefoot

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

304NotModified avatar Jun 12 '19 23:06 304NotModified

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.

304NotModified avatar Jun 12 '19 23:06 304NotModified