You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2012/09/26 00:40:18 UTC

XML config style

In the guide I read:

<?xml version="1.0" encoding="UTF-8"?><configuration status="OFF">
  <appenders>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level
%logger{36} - %msg%n"/>
    </Console>

Some tags start with a lower case, some with an upper case.

Can we be consistent please?

Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: XML config style

Posted by Ralph Goers <ra...@dslextreme.com>.
On Sep 26, 2012, at 8:32 AM, Gary Gregory wrote:

> On Wed, Sep 26, 2012 at 11:04 AM, Ralph Goers <ra...@dslextreme.com> wrote:
> Have you guys read http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax? In particular the "strict" and "schema" attributes.
> 
> IMO, using a schema for the concise format would be very impractical.  Personally, I'm not sure it makes sense even for the strict format as it would have to "know" about the attributes the various Appenders and Filters can accept to be of any value.  The schema would also have to be updated as new components are added. 
> 
> Well, yes, that's the whole point!
> 
> With an XSD, you can also generate code with JAXB, or you can annotate classes and have JAXB generate the schema.

Yes - we use JAXB for for our REST services. But I can't imagine why I'd want to use it with a Log4j configuration file.  I originally considered it, along with several other approaches, but discarded it as a way to do configuration.  Remember, one of the goals is to make it easy for users to add custom components. If they do that they would have to add their definitions to the schema.  Not a showstopper, but it will create maintenance issues as we update the schema.

Ralph


Re: XML config style

Posted by Gary Gregory <ga...@gmail.com>.
On Wed, Sep 26, 2012 at 11:04 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> Have you guys read
> http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax? In
> particular the "strict" and "schema" attributes.
>
> IMO, using a schema for the concise format would be very impractical.
>  Personally, I'm not sure it makes sense even for the strict format as it
> would have to "know" about the attributes the various Appenders and Filters
> can accept to be of any value.  The schema would also have to be updated as
> new components are added.
>

Well, yes, that's the whole point!

With an XSD, you can also generate code with JAXB, or you can annotate
classes and have JAXB generate the schema.

Gary


>
> Ralph
>
>
> On Sep 26, 2012, at 6:55 AM, Paul Benedict wrote:
>
> It's true that validation can add a bit of grogginess to the system.
> However, that can simply be controlled by a Java system property if
> necessary. I don't think we need the validation at runtime, however, having
> an XSD at design time is a definite. I need all the help I can get inside
> Eclipse :-)
>
> If not already, we should provide an XSD in the log4j api or impl jar.
>
> Paul
>
> On Wed, Sep 26, 2012 at 8:07 AM, Ivan Habunek <iv...@gmail.com>wrote:
>
>> On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
>> > Incorrect!
>>
>> I stand corrected. Still, it's probably not wise to have automatic XSD
>> validation before configuration because of performance issues. But it
>> would be nice to have a method which users can call and validate their
>> XML configuration files manually.
>>
>> Regards,
>> Ivan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>
>>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: XML config style

Posted by Ralph Goers <ra...@dslextreme.com>.
That is true. But it also means you aren't validating much.  

Ralph

On Sep 26, 2012, at 8:25 AM, Paul Benedict wrote:

> IIRC, XSD has an <xsd:any> type that allows you to accept any element. This allows a flexible schema.
> 
> On Wed, Sep 26, 2012 at 10:04 AM, Ralph Goers <ra...@dslextreme.com> wrote:
> Have you guys read http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax? In particular the "strict" and "schema" attributes.
> 
> IMO, using a schema for the concise format would be very impractical.  Personally, I'm not sure it makes sense even for the strict format as it would have to "know" about the attributes the various Appenders and Filters can accept to be of any value.  The schema would also have to be updated as new components are added. 
> 
> Ralph
> 
> 
> On Sep 26, 2012, at 6:55 AM, Paul Benedict wrote:
> 
>> It's true that validation can add a bit of grogginess to the system. However, that can simply be controlled by a Java system property if necessary. I don't think we need the validation at runtime, however, having an XSD at design time is a definite. I need all the help I can get inside Eclipse :-)
>> 
>> If not already, we should provide an XSD in the log4j api or impl jar.
>> 
>> Paul
>> 
>> On Wed, Sep 26, 2012 at 8:07 AM, Ivan Habunek <iv...@gmail.com> wrote:
>> On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
>> > Incorrect!
>> 
>> I stand corrected. Still, it's probably not wise to have automatic XSD
>> validation before configuration because of performance issues. But it
>> would be nice to have a method which users can call and validate their
>> XML configuration files manually.
>> 
>> Regards,
>> Ivan
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>> 
>> 
> 
> 


Re: XML config style

Posted by Paul Benedict <pb...@apache.org>.
IIRC, XSD has an <xsd:any> type that allows you to accept any element. This
allows a flexible schema.

On Wed, Sep 26, 2012 at 10:04 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> Have you guys read
> http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax? In
> particular the "strict" and "schema" attributes.
>
> IMO, using a schema for the concise format would be very impractical.
>  Personally, I'm not sure it makes sense even for the strict format as it
> would have to "know" about the attributes the various Appenders and Filters
> can accept to be of any value.  The schema would also have to be updated as
> new components are added.
>
> Ralph
>
>
> On Sep 26, 2012, at 6:55 AM, Paul Benedict wrote:
>
> It's true that validation can add a bit of grogginess to the system.
> However, that can simply be controlled by a Java system property if
> necessary. I don't think we need the validation at runtime, however, having
> an XSD at design time is a definite. I need all the help I can get inside
> Eclipse :-)
>
> If not already, we should provide an XSD in the log4j api or impl jar.
>
> Paul
>
> On Wed, Sep 26, 2012 at 8:07 AM, Ivan Habunek <iv...@gmail.com>wrote:
>
>> On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
>> > Incorrect!
>>
>> I stand corrected. Still, it's probably not wise to have automatic XSD
>> validation before configuration because of performance issues. But it
>> would be nice to have a method which users can call and validate their
>> XML configuration files manually.
>>
>> Regards,
>> Ivan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>
>>
>
>

Re: XML config style

Posted by Ralph Goers <ra...@dslextreme.com>.
Have you guys read http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax? In particular the "strict" and "schema" attributes.

IMO, using a schema for the concise format would be very impractical.  Personally, I'm not sure it makes sense even for the strict format as it would have to "know" about the attributes the various Appenders and Filters can accept to be of any value.  The schema would also have to be updated as new components are added. 

Ralph

On Sep 26, 2012, at 6:55 AM, Paul Benedict wrote:

> It's true that validation can add a bit of grogginess to the system. However, that can simply be controlled by a Java system property if necessary. I don't think we need the validation at runtime, however, having an XSD at design time is a definite. I need all the help I can get inside Eclipse :-)
> 
> If not already, we should provide an XSD in the log4j api or impl jar.
> 
> Paul
> 
> On Wed, Sep 26, 2012 at 8:07 AM, Ivan Habunek <iv...@gmail.com> wrote:
> On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
> > Incorrect!
> 
> I stand corrected. Still, it's probably not wise to have automatic XSD
> validation before configuration because of performance issues. But it
> would be nice to have a method which users can call and validate their
> XML configuration files manually.
> 
> Regards,
> Ivan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 
> 


Re: XML config style

Posted by Paul Benedict <pb...@apache.org>.
It's true that validation can add a bit of grogginess to the system.
However, that can simply be controlled by a Java system property if
necessary. I don't think we need the validation at runtime, however, having
an XSD at design time is a definite. I need all the help I can get inside
Eclipse :-)

If not already, we should provide an XSD in the log4j api or impl jar.

Paul

On Wed, Sep 26, 2012 at 8:07 AM, Ivan Habunek <iv...@gmail.com>wrote:

> On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
> > Incorrect!
>
> I stand corrected. Still, it's probably not wise to have automatic XSD
> validation before configuration because of performance issues. But it
> would be nice to have a method which users can call and validate their
> XML configuration files manually.
>
> Regards,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>

Re: XML config style

Posted by Ivan Habunek <iv...@gmail.com>.
On 26 September 2012 13:39, Gary Gregory <ga...@gmail.com> wrote:
> Incorrect!

I stand corrected. Still, it's probably not wise to have automatic XSD
validation before configuration because of performance issues. But it
would be nice to have a method which users can call and validate their
XML configuration files manually.

Regards,
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: XML config style

Posted by Gary Gregory <ga...@gmail.com>.
On Wed, Sep 26, 2012 at 2:21 AM, Ivan Habunek <iv...@gmail.com>wrote:

> On 26 September 2012 08:12, Gary Gregory <ga...@gmail.com> wrote:
> > Furthermore, if we do XML, we should deliver an XML Schema.
>
> Having a schema is always good. But if you're tempted to do automatic
> validation of config files using the schema, I suggest you don't.
>
> I implemented automatic XSD validation in log4php to see how it works,
> but i found it too restrictive. The main problem is that it does not
> allow out of order elements.


Incorrect!

If you want to allow:

<?xml version="1.0" encoding="UTF-8"?>
<Root xsi:noNamespaceSchemaLocation="Untitled1.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
    <B>text</B>
    <A>text</A>
</Root>

and:

<?xml version="1.0" encoding="UTF-8"?>
<Root xsi:noNamespaceSchemaLocation="Untitled1.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
    <A>text</A>
    <B>text</B>
</Root>

then just say:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="Root">
        <xs:annotation>
            <xs:documentation>Comment describing your root
element</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:all>
                <xs:element name="A"/>
                <xs:element name="B"/>
            </xs:all>
        </xs:complexType>
    </xs:element>
</xs:schema>

Gary


> For example, if you define first
> <appender> then <logger> node in schema, the validation will report
> errors if it's the config file has them the other way around. So I
> decided to remove it.
>
> Just my 2p.
>
> Regards,
> Ivan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: XML config style

Posted by Ivan Habunek <iv...@gmail.com>.
On 26 September 2012 08:12, Gary Gregory <ga...@gmail.com> wrote:
> Furthermore, if we do XML, we should deliver an XML Schema.

Having a schema is always good. But if you're tempted to do automatic
validation of config files using the schema, I suggest you don't.

I implemented automatic XSD validation in log4php to see how it works,
but i found it too restrictive. The main problem is that it does not
allow out of order elements. For example, if you define first
<appender> then <logger> node in schema, the validation will report
errors if it's the config file has them the other way around. So I
decided to remove it.

Just my 2p.

Regards,
Ivan

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: XML config style

Posted by Gary Gregory <ga...@gmail.com>.
On Wed, Sep 26, 2012 at 2:01 AM, Noel Grandin <no...@peralex.com> wrote:

>
> On 2012-09-26 04:01, Ralph Goers wrote:
>
>> Almost everything is case insensitive.  You can spell it appenders,
>> Appenders, APPENDERS or aPpEnDeRs.
>>
>>
>>  That's probably not a good idea long term.
> XML is case-sensitive by default, thus most of the XML tools are also case
> sensitive.
>
> If someone decides to develop an XSD schema to parse this stuff they're
> going to run into trouble.
>
> Probably best to
> (a) pick a normative style from now on
>

+1

Furthermore, if we do XML, we should deliver an XML Schema.

G


> (b) initially just generate a warning if people use the "wrong" case
>
>
> Disclaimer: http://www.peralex.com/**disclaimer.html<http://www.peralex.com/disclaimer.html>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.**apache.org<lo...@logging.apache.org>
> For additional commands, e-mail: log4j-dev-help@logging.apache.**org<lo...@logging.apache.org>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: XML config style

Posted by Noel Grandin <no...@peralex.com>.
On 2012-09-26 04:01, Ralph Goers wrote:
> Almost everything is case insensitive.  You can spell it appenders, 
> Appenders, APPENDERS or aPpEnDeRs.
>
>
That's probably not a good idea long term.
XML is case-sensitive by default, thus most of the XML tools are also 
case sensitive.

If someone decides to develop an XSD schema to parse this stuff they're 
going to run into trouble.

Probably best to
(a) pick a normative style from now on
(b) initially just generate a warning if people use the "wrong" case


Disclaimer: http://www.peralex.com/disclaimer.html



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: XML config style

Posted by Ralph Goers <ra...@dslextreme.com>.
Almost everything is case insensitive.  You can spell it appenders, Appenders, APPENDERS or aPpEnDeRs.

Sure, the examples could be made to be more consistent.  Patches are welcome!

Ralph

On Sep 25, 2012, at 3:40 PM, Gary Gregory wrote:

> In the guide I read:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="OFF">
>   <appenders>
>     <Console name="Console" target="SYSTEM_OUT">
>       <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
>     </Console>
> 
> Some tags start with a lower case, some with an upper case. 
> 
> Can we be consistent please? 
> 
> Gary
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
> Spring Batch in Action: http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory