And here's how I'm changing it now that there's a builder class in
HtmlLayout:

        final HtmlLayout layout = HtmlLayout.newBuilder()
            .withLocationInfo(includeLocation)
            .build();

Bam!


On 25 May 2014 17:20, Matt Sicker <[email protected]> wrote:

> As I showed in the HtmlLayoutTest, I have a certain workaround to re-using
> default values. The main idea is:
>
> Node node = new Node();
> Map<String, String> attrs = node.getAttributes();
> node.put("foo", "bar"); // for all non-default attributes
> FooPlugin f = new PluginBuilder<FooPlugin>(new
> PluginType<FooPlugin>(FooPlugin.class, "FooPlugin", false, false))
>             .withFactoryMethodAnnotatedBy(PluginFactory.class)
>             .withConfiguration(new DefaultConfiguration())
>             .withConfigurationNode(node)
>             .forLogEvent(new Log4jLogEvent())
>             .build();
>
> It's actually a nice example as to why I think LOG4J2-653 is another
> useful feature for us as developers. I'll work on a proof of concept
> sometime soon. It helps to get an idea on how I might do it as I'm working
> on converting these other plugins.
>
> I'll take a look at any failing unit tests. I guess I missed some due to
> neglecting the non-core modules. :(
>
> ---------- Forwarded message ----------
> From: <[email protected]>
> Date: 25 May 2014 07:05
> Subject: svn commit: r1597421 - in /logging/log4j/log4j2/trunk:
> log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java
> log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
> To: [email protected]
>
>
> Author: rpopma
> Date: Sun May 25 12:05:37 2014
> New Revision: 1597421
>
> URL: http://svn.apache.org/r1597421
> Log:
> Fixed compile error in FlumeAppender.createAppender(): the
> Rfc5424Layout.createLayout() method was refactored to use strongly typed
> parameters but FlumeAppender was not updated. Also fixed
> FlumeAppender.createAppender to pass non-null MDCID to
> Rfc5424Layout.createLayout(): when called from JUnit tests, the @Default
> annotation does not replace nulls with default values and the null values
> cause errors downstream. This solved one problem in FlumeAppender JUnit
> tests but they are still failing... Matt, can you take a look?
>
> Modified:
>
> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java
>
> logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
>
> Modified:
> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java
> URL:
> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java?rev=1597421&r1=1597420&r2=1597421&view=diff
>
> ==============================================================================
> ---
> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java
> (original)
> +++
> logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/Rfc5424Layout.java
> Sun May 25 12:05:37 2014
> @@ -82,7 +82,7 @@ public final class Rfc5424Layout extends
>       */
>      public static final Pattern PARAM_VALUE_ESCAPE_PATTERN =
> Pattern.compile("[\\\"\\]\\\\]");
>
> -    protected static final String DEFAULT_MDCID = "mdc";
> +    public static final String DEFAULT_MDCID = "mdc";
>      private static final int TWO_DIGITS = 10;
>      private static final int THREE_DIGITS = 100;
>      private static final int MILLIS_PER_MINUTE = 60000;
>
> Modified:
> logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
> URL:
> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java?rev=1597421&r1=1597420&r2=1597421&view=diff
>
> ==============================================================================
> ---
> logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
> (original)
> +++
> logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java
> Sun May 25 12:05:37 2014
> @@ -219,8 +219,10 @@ public final class FlumeAppender extends
>          final int delay = Integers.parseInt(maxDelay, DEFAULT_MAX_DELAY);
>
>          if (layout == null) {
> -            layout = Rfc5424Layout.createLayout(null, null, null, "True",
> null, mdcPrefix, eventPrefix,
> -                    null, null, null, null, excludes, includes, required,
> null, null, null, null);
> +            final int enterpriseNumber =
> Integer.parseInt(Rfc5424Layout.DEFAULT_ENTERPRISE_NUMBER);
> +            layout = Rfc5424Layout.createLayout(null, null,
> enterpriseNumber, true, Rfc5424Layout.DEFAULT_MDCID,
> +                    mdcPrefix, eventPrefix, false, null, null, null,
> excludes, includes, required, null, false, null,
> +                    null);
>          }
>
>          if (name == null) {
>
>
>
>
>
> --
> Matt Sicker <[email protected]>
>



-- 
Matt Sicker <[email protected]>

Reply via email to