You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "zi4k4j74yn (via GitHub)" <gi...@apache.org> on 2023/04/29 08:06:23 UTC

[I] XML config from documentation does not validate against schema (file appender) (logging-log4j2)

zi4k4j74yn opened a new issue, #1456:
URL: https://github.com/apache/logging-log4j2/issues/1456

   ## Description
   
   I am using the example configuration from https://logging.apache.org/log4j/2.x/manual/appenders.html#FileAppender and just added the schema configuration:
   
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <Configuration xmlns="http://logging.apache.org/log4j/2.0/config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config https://raw.githubusercontent.com/apache/logging-log4j2/master/log4j-core/src/main/resources/Log4j-config.xsd" status="warn" name="MyApp">
     <Appenders>
       <File name="MyFile" fileName="logs/app.log">
         <PatternLayout>
           <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
         </PatternLayout>
       </File>
     </Appenders>
     <Loggers>
       <Root level="error">
         <AppenderRef ref="MyFile"/>
       </Root>
     </Loggers>
   </Configuration>
   ```
   
   This config fails to validate against https://raw.githubusercontent.com/apache/logging-log4j2/master/log4j-core/src/main/resources/Log4j-config.xsd (error below).
   
   ## Configuration
   
   **Version:** 2.20.0
   
   **Operating system:** Ubuntu 22.04
   
   **JDK:** OpenJDK 20
   
   ## Logs
   
   Message from [xmllint](https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home):
   ```
   log4j2.xml:6: element File: Schemas validity error : Element '{http://logging.apache.org/log4j/2.0/config}File': This element is not expected. Expected is one of ( {http://logging.apache.org/log4j/2.0/config}Appender, {http://logging.apache.org/log4j/2.0/config}Console ).
   log4j2.xml fails to validate
   ```
   
   Eclipse gives a similar error:
   
   ```
   cvc-complex-types.2.4.d: Invalid content was found starting with element 'File'. [...]
   ```
   
   ## Reproduction
   
   Create config file as specified and verify against linked schema (either via `xmllint --noout --schema Log4j-config.xsd log4j2.xml` or via Eclipse).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] XML config from documentation does not validate against schema (file appender) (logging-log4j2)

Posted by "zi4k4j74yn (via GitHub)" <gi...@apache.org>.
zi4k4j74yn commented on issue #1456:
URL: https://github.com/apache/logging-log4j2/issues/1456#issuecomment-1528784795

   My bad, I did not see the main branch. Thank you a lot for the clarification!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] XML config from documentation does not validate against schema (file appender) (logging-log4j2)

Posted by "zi4k4j74yn (via GitHub)" <gi...@apache.org>.
zi4k4j74yn closed issue #1456: XML config from documentation does not validate against schema (file appender)
URL: https://github.com/apache/logging-log4j2/issues/1456


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] XML config from documentation does not validate against schema (file appender) (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1456:
URL: https://github.com/apache/logging-log4j2/issues/1456#issuecomment-1528782021

   @zi4k4j74yn,
   
   We renamed `master` to `main` a couple of months ago. So this is the current schema on master: https://raw.githubusercontent.com/apache/logging-log4j2/main/log4j-core/src/main/resources/Log4j-config.xsd
   
   However, similarly to Ant and Maven, Log4j's configuration is schema-less: unless you are using the [strict XML syntax](https://logging.apache.org/log4j/2.x/manual/configuration.html#strict-xml) (which you are not), you can not verify every valid Log4j configuration with a schema.
   
   The one we provide only contains (part of) the definitions of those components maintained by Apache Logging Services, but there are also many custom components developed by third parties.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org