Thanks for the help to everyone; I also received a similar response on
Stack Overflow. Below is the corrected xml file that will validate. The
one item I can't seem to specify is the max file size for the file appender
(its not a rolling appender).
1. The schema does not have an Appender called File defined a type of
File is used.
2. The schema defines that the Root node occurs after all the Logger
nodes
<?xml version="1.0" encoding="UTF-8"?>
<Configuration strict="true"
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/log4j-2.11.1/log4j-c
ore/src/main/resources/Log4j-config.xsd">
<Appenders>
<Appender type="File" name="file" fileName="mylogfile.log">
<Layout type="PatternLayout" pattern="%d{yyyy-MM-dd HH:mm:ss
z} %-5level - %msg%n" />
</Appender>
<Appender type="Console" name="console">
<Layout type="PatternLayout" pattern="%d{yyyy-MM-dd HH:mm:ss
z} %-5level - %msg%n" />
</Appender>
</Appenders>
<Loggers>
<Logger name="org.apache.http" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="net.authorize.util" level="WARN"
additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="net.authorize.api" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="com.amazonaws" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Root level="DEBUG">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Root>
</Loggers>
</Configuration>
Thank you
.ed
Ed Zappulla
BSG Systems, LLC
17 Red Tail Hawk Ct
Annandale, NJ 08801
Mobile: (908) 246-5304
Email: [email protected]
-----Original Message-----
From: Ralph Goers [mailto:[email protected]]
Sent: Friday, January 04, 2019 12:42 AM
To: Log4J Users List <[email protected]>
Subject: Re: Lohg4j2 Schema Errors
You have specified strict= true but then not followed the format required
when that attribute is specified. See the example at
<https://logging.apache.org/log4j/2.x/manual/configuration.html#Configuratio
n_Syntax>
https://logging.apache.org/log4j/2.x/manual/configuration.html#Configuration
_Syntax under the sentence that reads "Below is a sample configuration using
the strict format.
Note that individual Filters, Appenders, Layouts, etc. can have attributes
or children that the XML schema doesn t know anything about and won t really
validate.
Ralph
> On Jan 3, 2019, at 6:41 AM, Ed Zappulla <
<mailto:[email protected]> [email protected]> wrote:
>
> I'm having trouble getting my log4j2.xml file to conform to the schema.
> Without the schema specification I don't have any errors but with it
> in place I am getting:
>
> cvc-complex-type.2.4.d: Invalid content was found starting with
> element 'File'. No child element is expected at
>
> this point.
>
>
>
> cvc-complex-type.2.4.d: Invalid content was found starting with
> element 'Logger'. No child element is expected
>
> at this point.
>
>
>
> The logging works fine without the schema but Eclipse is warning that
> its missing so I would like to have it in place. This is the
> log4j2.xml file I'm
> using:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Configuration strict="true"
> xmlns=" <http://logging.apache.org/log4j/2.0/config>
http://logging.apache.org/log4j/2.0/config"
> xmlns:xsi=" <http://www.w3.org/2001/XMLSchema-instance>
http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config
>
> <https://raw.githubusercontent.com/apache/logging-log4j2/log4j-2.11.1/l>
https://raw.githubusercontent.com/apache/logging-log4j2/log4j-2.11.1/l
> og4j-c ore/src/main/resources/Log4j-config.xsd">
>
> <Appenders>
>
> <Console name="console" target="SYSTEM_OUT">
> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss z} %-5p %-5level -
> %msg%n"/>
> </Console>
>
> <File name="file" fileName="mylogfile.log" append="true">
> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss z} %-5p %-5level -
> %msg%n"/>
> </File >
> </Appenders>
>
>
> <Loggers>
> <Root level="DEBUG">
> <AppenderRef ref="console"/>
> <AppenderRef ref="file"/>
> </Root>
>
> <Logger name="org.apache.http" level="WARN" additivity="false">
> <AppenderRef ref="console"/>
> <AppenderRef ref="file"/>
> </Logger>
>
> <Logger name="net.authorize.util" level="WARN" additivity="false">
> <AppenderRef ref="console"/>
> <AppenderRef ref="file"/>
> </Logger>
>
> <Logger name="net.authorize.api" level="WARN" additivity="false">
> <AppenderRef ref="console"/>
> <AppenderRef ref="file"/>
> </Logger>
>
> </Loggers>
>
> </Configuration>
>
>
>
>
>
> Any help would be appreciated.
>
>
>
>
>
> Thank you
>
>
>
> .ed
>
>
>
>
>