Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
304NotModified opened this issue Jun 11, 2019 · 7 comments
Open

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

304NotModified opened this issue Jun 11, 2019 · 7 comments
Labels
bug Bug report / Bug fix XSD change

Comments

@304NotModified
Copy link
Member

related #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 304NotModified added this to the 4.6.5 milestone Jun 11, 2019
@304NotModified 304NotModified added the bug Bug report / Bug fix label Jun 11, 2019
@snakefoot
Copy link
Contributor

snakefoot commented Jun 11, 2019

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

@304NotModified
Copy link
Member Author

Strange that it doesn't inherit -item from WrapperTargetBase

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

@304NotModified
Copy link
Member Author

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)

@snakefoot
Copy link
Contributor

snakefoot commented Jun 11, 2019

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
Copy link
Contributor

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

@304NotModified 304NotModified modified the milestones: 4.6.5, 4.6.6 Jun 12, 2019
@304NotModified
Copy link
Member Author

304NotModified commented Jun 12, 2019

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
Copy link
Member Author

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 304NotModified modified the milestones: 4.6.6, 4.6.7 Jul 14, 2019
@304NotModified 304NotModified modified the milestones: 4.6.7, 4.6.8 Aug 22, 2019
@304NotModified 304NotModified modified the milestones: 4.6.8, 4.7 Oct 25, 2019
@304NotModified 304NotModified removed this from the 4.7 milestone Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report / Bug fix XSD change
Projects
None yet
Development

No branches or pull requests

2 participants