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 Remko Popma <re...@gmail.com> on 2016/11/17 00:01:21 UTC

Re: logging-log4j2 git commit: [LOG4J2-1379] Add documentation on YAML format

Thanks Matt, good stuff!
Quick question: why are the loggers in the configuration prefixed with a line containing a hyphen '-', while Appenders are not?
PS did you try the config to make sure it works?

Sent from my iPhone

> On 17 Nov 2016, at 5:24, mattsicker@apache.org wrote:
> 
> Repository: logging-log4j2
> Updated Branches:
>  refs/heads/master 0a9e99f93 -> 220aeb7ef
> 
> 
> [LOG4J2-1379] Add documentation on YAML format
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/220aeb7e
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/220aeb7e
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/220aeb7e
> 
> Branch: refs/heads/master
> Commit: 220aeb7ef45de5b73a1b4511e9425e407ad73683
> Parents: 0a9e99f
> Author: Matt Sicker <bo...@gmail.com>
> Authored: Wed Nov 16 14:24:29 2016 -0600
> Committer: Matt Sicker <bo...@gmail.com>
> Committed: Wed Nov 16 14:24:29 2016 -0600
> 
> ----------------------------------------------------------------------
> src/changes/changes.xml                   |  3 ++
> src/site/site.xml                         |  1 +
> src/site/xdoc/manual/configuration.xml.vm | 66 ++++++++++++++++++++++++++
> 3 files changed, 70 insertions(+)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/changes/changes.xml
> ----------------------------------------------------------------------
> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> index 10ee145..b9e12e3 100644
> --- a/src/changes/changes.xml
> +++ b/src/changes/changes.xml
> @@ -129,6 +129,9 @@
>       <action issue="LOG4J2-1700" dev="ggregory" type="update">
>         Update Jansi from 1.13 to 1.14.
>       </action>
> +      <action issue="LOG4J2-1379" dev="mattsicker" type="add">
> +        Add documentation regarding YAML configuration format.
> +      </action>
>       <action issue="LOG4J2-1681" dev="rpopma" type="add">
>         Changed visibility of indexed getter methods in SortedArrayStringMap from package-protected to public.
>       </action>
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/site/site.xml
> ----------------------------------------------------------------------
> diff --git a/src/site/site.xml b/src/site/site.xml
> index 3c63ef2..b69d3a1 100644
> --- a/src/site/site.xml
> +++ b/src/site/site.xml
> @@ -81,6 +81,7 @@
>         <item name="Configuration Syntax" href="/manual/configuration.html#ConfigurationSyntax" />
>         <item name="XML Syntax" href="/manual/configuration.html#XML"/>
>         <item name="JSON Syntax" href="/manual/configuration.html#JSON"/>
> +        <item name="YAML Syntax" href="/manual/configuration.html#YAML"/>
>         <item name="Properties Syntax" href="/manual/configuration.html#Properties"/>
>         <item name="Configuring Loggers" href="/manual/configuration.html#Loggers"/>
>         <item name="Configuring Appenders" href="/manual/configuration.html#Appenders"/>
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/site/xdoc/manual/configuration.xml.vm
> ----------------------------------------------------------------------
> diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
> index 2117dd2..05522c1 100644
> --- a/src/site/xdoc/manual/configuration.xml.vm
> +++ b/src/site/xdoc/manual/configuration.xml.vm
> @@ -695,6 +695,72 @@ public class Bar {
>   <version>${jackson2Version}</version>
> </dependency>
> ]]></pre>
> +          <a name="YAML"/>
> +          <h4>Configuration with YAML</h4>
> +          <p>
> +            Log4j also supports using YAML for configuration files. The structure follows the same pattern as both the
> +            XML and YAML configuration formats. For example:
> +          </p>
> +          <pre class="prettyprint linenums"><![CDATA[
> +Configuration:
> +  status: warn
> +  name: YAMLConfigTest
> +  properties:
> +    property:
> +      name: filename
> +      value: target/test-yaml.log
> +  thresholdFilter:
> +    level: debug
> +  appenders:
> +    Console:
> +      name: STDOUT
> +      PatternLayout:
> +        Pattern: "%m%n"
> +    File:
> +      name: File
> +      fileName: ${dollar}{filename}
> +      bufferedIO: false
> +      PatternLayout:
> +        Pattern: "%d %p %C{1.} [%t] %m%n"
> +    List:
> +      name: List
> +      Filters:
> +        ThresholdFilter:
> +          level: error
> +
> +  Loggers:
> +    logger:
> +      -
> +        name: org.apache.logging.log4j.test1
> +        level: debug
> +        additivity: false
> +        ThreadContextMapFilter:
> +          KeyValuePair:
> +            key: test
> +            value: 123
> +        AppenderRef:
> +          ref: STDOUT
> +      -
> +        name: org.apache.logging.log4j.test2
> +        level: debug
> +        additivity: false
> +        AppenderRef:
> +          ref: File
> +    Root:
> +      level: error
> +      AppenderRef:
> +        ref: STDOUT
> +          ]]></pre>
> +          <p>
> +            In order to use YAML configuration files, the Jackson YAML data format must be included:
> +          </p>
> +          <pre class="prettyprint linenums"><![CDATA[
> +<dependency>
> +    <groupId>com.fasterxml.jackson.dataformat</groupId>
> +    <artifactId>jackson-dataformat-yaml</artifactId>
> +    <version>${jackson2Version}</version>
> +</dependency>
> +          ]]></pre>
>         <a name="Loggers"/>
>           <h4>Configuring loggers</h4>
>           <p>
> 

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


Re: logging-log4j2 git commit: [LOG4J2-1379] Add documentation on YAML format

Posted by Remko Popma <re...@gmail.com>.
Interesting! Thanks for clarifying!

Sent from my iPhone

> On 17 Nov 2016, at 9:08, Matt Sicker <bo...@gmail.com> wrote:
> 
> That config is from a unit test, so I'd presume it works. As for the particular format of using the hyphens, it looks like it's necessary if you want to define more than one of the same plugin (e.g., a Logger or multiple FileAppenders).
> 
>> On 16 November 2016 at 18:01, Remko Popma <re...@gmail.com> wrote:
>> Thanks Matt, good stuff!
>> Quick question: why are the loggers in the configuration prefixed with a line containing a hyphen '-', while Appenders are not?
>> PS did you try the config to make sure it works?
>> 
>> Sent from my iPhone
>> 
>> > On 17 Nov 2016, at 5:24, mattsicker@apache.org wrote:
>> >
>> > Repository: logging-log4j2
>> > Updated Branches:
>> >  refs/heads/master 0a9e99f93 -> 220aeb7ef
>> >
>> >
>> > [LOG4J2-1379] Add documentation on YAML format
>> >
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> > Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/220aeb7e
>> > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/220aeb7e
>> > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/220aeb7e
>> >
>> > Branch: refs/heads/master
>> > Commit: 220aeb7ef45de5b73a1b4511e9425e407ad73683
>> > Parents: 0a9e99f
>> > Author: Matt Sicker <bo...@gmail.com>
>> > Authored: Wed Nov 16 14:24:29 2016 -0600
>> > Committer: Matt Sicker <bo...@gmail.com>
>> > Committed: Wed Nov 16 14:24:29 2016 -0600
>> >
>> > ----------------------------------------------------------------------
>> > src/changes/changes.xml                   |  3 ++
>> > src/site/site.xml                         |  1 +
>> > src/site/xdoc/manual/configuration.xml.vm | 66 ++++++++++++++++++++++++++
>> > 3 files changed, 70 insertions(+)
>> > ----------------------------------------------------------------------
>> >
>> >
>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/changes/changes.xml
>> > ----------------------------------------------------------------------
>> > diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>> > index 10ee145..b9e12e3 100644
>> > --- a/src/changes/changes.xml
>> > +++ b/src/changes/changes.xml
>> > @@ -129,6 +129,9 @@
>> >       <action issue="LOG4J2-1700" dev="ggregory" type="update">
>> >         Update Jansi from 1.13 to 1.14.
>> >       </action>
>> > +      <action issue="LOG4J2-1379" dev="mattsicker" type="add">
>> > +        Add documentation regarding YAML configuration format.
>> > +      </action>
>> >       <action issue="LOG4J2-1681" dev="rpopma" type="add">
>> >         Changed visibility of indexed getter methods in SortedArrayStringMap from package-protected to public.
>> >       </action>
>> >
>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/site/site.xml
>> > ----------------------------------------------------------------------
>> > diff --git a/src/site/site.xml b/src/site/site.xml
>> > index 3c63ef2..b69d3a1 100644
>> > --- a/src/site/site.xml
>> > +++ b/src/site/site.xml
>> > @@ -81,6 +81,7 @@
>> >         <item name="Configuration Syntax" href="/manual/configuration.html#ConfigurationSyntax" />
>> >         <item name="XML Syntax" href="/manual/configuration.html#XML"/>
>> >         <item name="JSON Syntax" href="/manual/configuration.html#JSON"/>
>> > +        <item name="YAML Syntax" href="/manual/configuration.html#YAML"/>
>> >         <item name="Properties Syntax" href="/manual/configuration.html#Properties"/>
>> >         <item name="Configuring Loggers" href="/manual/configuration.html#Loggers"/>
>> >         <item name="Configuring Appenders" href="/manual/configuration.html#Appenders"/>
>> >
>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/220aeb7e/src/site/xdoc/manual/configuration.xml.vm
>> > ----------------------------------------------------------------------
>> > diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
>> > index 2117dd2..05522c1 100644
>> > --- a/src/site/xdoc/manual/configuration.xml.vm
>> > +++ b/src/site/xdoc/manual/configuration.xml.vm
>> > @@ -695,6 +695,72 @@ public class Bar {
>> >   <version>${jackson2Version}</version>
>> > </dependency>
>> > ]]></pre>
>> > +          <a name="YAML"/>
>> > +          <h4>Configuration with YAML</h4>
>> > +          <p>
>> > +            Log4j also supports using YAML for configuration files. The structure follows the same pattern as both the
>> > +            XML and YAML configuration formats. For example:
>> > +          </p>
>> > +          <pre class="prettyprint linenums"><![CDATA[
>> > +Configuration:
>> > +  status: warn
>> > +  name: YAMLConfigTest
>> > +  properties:
>> > +    property:
>> > +      name: filename
>> > +      value: target/test-yaml.log
>> > +  thresholdFilter:
>> > +    level: debug
>> > +  appenders:
>> > +    Console:
>> > +      name: STDOUT
>> > +      PatternLayout:
>> > +        Pattern: "%m%n"
>> > +    File:
>> > +      name: File
>> > +      fileName: ${dollar}{filename}
>> > +      bufferedIO: false
>> > +      PatternLayout:
>> > +        Pattern: "%d %p %C{1.} [%t] %m%n"
>> > +    List:
>> > +      name: List
>> > +      Filters:
>> > +        ThresholdFilter:
>> > +          level: error
>> > +
>> > +  Loggers:
>> > +    logger:
>> > +      -
>> > +        name: org.apache.logging.log4j.test1
>> > +        level: debug
>> > +        additivity: false
>> > +        ThreadContextMapFilter:
>> > +          KeyValuePair:
>> > +            key: test
>> > +            value: 123
>> > +        AppenderRef:
>> > +          ref: STDOUT
>> > +      -
>> > +        name: org.apache.logging.log4j.test2
>> > +        level: debug
>> > +        additivity: false
>> > +        AppenderRef:
>> > +          ref: File
>> > +    Root:
>> > +      level: error
>> > +      AppenderRef:
>> > +        ref: STDOUT
>> > +          ]]></pre>
>> > +          <p>
>> > +            In order to use YAML configuration files, the Jackson YAML data format must be included:
>> > +          </p>
>> > +          <pre class="prettyprint linenums"><![CDATA[
>> > +<dependency>
>> > +    <groupId>com.fasterxml.jackson.dataformat</groupId>
>> > +    <artifactId>jackson-dataformat-yaml</artifactId>
>> > +    <version>${jackson2Version}</version>
>> > +</dependency>
>> > +          ]]></pre>
>> >         <a name="Loggers"/>
>> >           <h4>Configuring loggers</h4>
>> >           <p>
>> >
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>> 
> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>

Re: logging-log4j2 git commit: [LOG4J2-1379] Add documentation on YAML format

Posted by Matt Sicker <bo...@gmail.com>.
That config is from a unit test, so I'd presume it works. As for the
particular format of using the hyphens, it looks like it's necessary if you
want to define more than one of the same plugin (e.g., a Logger or multiple
FileAppenders).

On 16 November 2016 at 18:01, Remko Popma <re...@gmail.com> wrote:

> Thanks Matt, good stuff!
> Quick question: why are the loggers in the configuration prefixed with a
> line containing a hyphen '-', while Appenders are not?
> PS did you try the config to make sure it works?
>
> Sent from my iPhone
>
> > On 17 Nov 2016, at 5:24, mattsicker@apache.org wrote:
> >
> > Repository: logging-log4j2
> > Updated Branches:
> >  refs/heads/master 0a9e99f93 -> 220aeb7ef
> >
> >
> > [LOG4J2-1379] Add documentation on YAML format
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> > Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/
> commit/220aeb7e
> > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/
> 220aeb7e
> > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/
> 220aeb7e
> >
> > Branch: refs/heads/master
> > Commit: 220aeb7ef45de5b73a1b4511e9425e407ad73683
> > Parents: 0a9e99f
> > Author: Matt Sicker <bo...@gmail.com>
> > Authored: Wed Nov 16 14:24:29 2016 -0600
> > Committer: Matt Sicker <bo...@gmail.com>
> > Committed: Wed Nov 16 14:24:29 2016 -0600
> >
> > ----------------------------------------------------------------------
> > src/changes/changes.xml                   |  3 ++
> > src/site/site.xml                         |  1 +
> > src/site/xdoc/manual/configuration.xml.vm | 66
> ++++++++++++++++++++++++++
> > 3 files changed, 70 insertions(+)
> > ----------------------------------------------------------------------
> >
> >
> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
> 220aeb7e/src/changes/changes.xml
> > ----------------------------------------------------------------------
> > diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> > index 10ee145..b9e12e3 100644
> > --- a/src/changes/changes.xml
> > +++ b/src/changes/changes.xml
> > @@ -129,6 +129,9 @@
> >       <action issue="LOG4J2-1700" dev="ggregory" type="update">
> >         Update Jansi from 1.13 to 1.14.
> >       </action>
> > +      <action issue="LOG4J2-1379" dev="mattsicker" type="add">
> > +        Add documentation regarding YAML configuration format.
> > +      </action>
> >       <action issue="LOG4J2-1681" dev="rpopma" type="add">
> >         Changed visibility of indexed getter methods in
> SortedArrayStringMap from package-protected to public.
> >       </action>
> >
> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
> 220aeb7e/src/site/site.xml
> > ----------------------------------------------------------------------
> > diff --git a/src/site/site.xml b/src/site/site.xml
> > index 3c63ef2..b69d3a1 100644
> > --- a/src/site/site.xml
> > +++ b/src/site/site.xml
> > @@ -81,6 +81,7 @@
> >         <item name="Configuration Syntax" href="/manual/configuration.html#ConfigurationSyntax"
> />
> >         <item name="XML Syntax" href="/manual/configuration.html#XML"/>
> >         <item name="JSON Syntax" href="/manual/configuration.
> html#JSON"/>
> > +        <item name="YAML Syntax" href="/manual/configuration.
> html#YAML"/>
> >         <item name="Properties Syntax" href="/manual/configuration.
> html#Properties"/>
> >         <item name="Configuring Loggers" href="/manual/configuration.
> html#Loggers"/>
> >         <item name="Configuring Appenders" href="/manual/configuration.
> html#Appenders"/>
> >
> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/
> 220aeb7e/src/site/xdoc/manual/configuration.xml.vm
> > ----------------------------------------------------------------------
> > diff --git a/src/site/xdoc/manual/configuration.xml.vm
> b/src/site/xdoc/manual/configuration.xml.vm
> > index 2117dd2..05522c1 100644
> > --- a/src/site/xdoc/manual/configuration.xml.vm
> > +++ b/src/site/xdoc/manual/configuration.xml.vm
> > @@ -695,6 +695,72 @@ public class Bar {
> >   <version>${jackson2Version}</version>
> > </dependency>
> > ]]></pre>
> > +          <a name="YAML"/>
> > +          <h4>Configuration with YAML</h4>
> > +          <p>
> > +            Log4j also supports using YAML for configuration files. The
> structure follows the same pattern as both the
> > +            XML and YAML configuration formats. For example:
> > +          </p>
> > +          <pre class="prettyprint linenums"><![CDATA[
> > +Configuration:
> > +  status: warn
> > +  name: YAMLConfigTest
> > +  properties:
> > +    property:
> > +      name: filename
> > +      value: target/test-yaml.log
> > +  thresholdFilter:
> > +    level: debug
> > +  appenders:
> > +    Console:
> > +      name: STDOUT
> > +      PatternLayout:
> > +        Pattern: "%m%n"
> > +    File:
> > +      name: File
> > +      fileName: ${dollar}{filename}
> > +      bufferedIO: false
> > +      PatternLayout:
> > +        Pattern: "%d %p %C{1.} [%t] %m%n"
> > +    List:
> > +      name: List
> > +      Filters:
> > +        ThresholdFilter:
> > +          level: error
> > +
> > +  Loggers:
> > +    logger:
> > +      -
> > +        name: org.apache.logging.log4j.test1
> > +        level: debug
> > +        additivity: false
> > +        ThreadContextMapFilter:
> > +          KeyValuePair:
> > +            key: test
> > +            value: 123
> > +        AppenderRef:
> > +          ref: STDOUT
> > +      -
> > +        name: org.apache.logging.log4j.test2
> > +        level: debug
> > +        additivity: false
> > +        AppenderRef:
> > +          ref: File
> > +    Root:
> > +      level: error
> > +      AppenderRef:
> > +        ref: STDOUT
> > +          ]]></pre>
> > +          <p>
> > +            In order to use YAML configuration files, the Jackson YAML
> data format must be included:
> > +          </p>
> > +          <pre class="prettyprint linenums"><![CDATA[
> > +<dependency>
> > +    <groupId>com.fasterxml.jackson.dataformat</groupId>
> > +    <artifactId>jackson-dataformat-yaml</artifactId>
> > +    <version>${jackson2Version}</version>
> > +</dependency>
> > +          ]]></pre>
> >         <a name="Loggers"/>
> >           <h4>Configuring loggers</h4>
> >           <p>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>


-- 
Matt Sicker <bo...@gmail.com>