logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: logging-log4j2 git commit: [LOG4J2-1482] Improper header in CsvParameterLayout.
Date Fri, 05 Aug 2016 00:02:20 GMT
Remko,

Thank you for the feedback. I will perform the code fiddling, this will
simplify the current solution.

Gary

On Thu, Aug 4, 2016 at 4:30 PM, Remko Popma <remko.popma@gmail.com> wrote:

> I did take a quick look yesterday. I was wrong about StrSubstitutor, looks
> like the full range of PatternLayout converters needs to be supported.
>
> Layouts may be used concurrently by multiple threads and creating a new
> LogEvent for each header/footer is the easiest way to deal with that.
>
> I would prefer the creation to happen in a single place, with subclasses
> being unaware of this, like it was before. This would give more flexibility
> if we ever want to make changes like making it garbagefree.
>
> So I would use the DefaultLogEventFactory where it used to say rootLogger.
> getLogEventFactory(), and let subclasses be unaware that a
> LogEventFactory is in play.
>
> Sent from my iPhone
>
> On 2016/08/05, at 2:34, Gary Gregory <garydgregory@gmail.com> wrote:
>
> Hi Remko,
>
> Where you planning on seeing what it would take to avoid creating a
> temporary log event?
>
> Gary
>
> On Wed, Aug 3, 2016 at 6:27 PM, Gary Gregory <garydgregory@gmail.com>
> wrote:
>
>> I implemented the fix this way because it seems wrong to have the default
>> log event factory coded in the AbstactStringLayout. Right now this use case
>> is only for headers and footers. So the changes make that explicit by
>> accessing the default log event factory from the header and footer methods.
>>
>> Yes, it would be nice if we did not need a dummy log event in the first
>> place to create headers and footers. I was worried that going down that
>> road would be too big of a change.
>>
>> I am open to fixing this differently of course. At least, we now have
>> unit tests :-)
>>
>> > The problem seems to be in Serializer. It is still unclear to me why
>> Serializer needs a LogEvent, (away from PC now) but I assume it is because
>> of StrSubstitutor.
>>
>> Yeah, needs a bit more digging.
>>
>> > I would like it much better if StrSubstitutor could be fixed so that a
>> LogEvent becomes optional, or, if that is not feasible,
>>
>> Yeah, maybe it's a matter of passing null for the log event and making
>> sure we have null checks in the right places.
>>
>> Gary
>>
>> On Wed, Aug 3, 2016 at 4:09 PM, Remko Popma <remko.popma@gmail.com>
>> wrote:
>>
>>> Why is this fixed in AbstactStringLayout, with ripple effect to JSON and
>>> YAML layouts?
>>>
>>> The problem seems to be in Serializer. It is still unclear to me why
>>> Serializer needs a LogEvent, (away from PC now) but I assume it is because
>>> of StrSubstitutor.
>>>
>>> I would like it much better if StrSubstitutor could be fixed so that a
>>> LogEvent becomes optional, or, if that is not feasible,
>>>
>>> Sent from my iPhone
>>>
>>> > On 2016/08/04, at 7:03, ggregory@apache.org wrote:
>>> >
>>> > Repository: logging-log4j2
>>> > Updated Branches:
>>> >  refs/heads/master 0f1b0dc00 -> ffc6c8f68
>>> >
>>> >
>>> > [LOG4J2-1482] Improper header in CsvParameterLayout.
>>> >
>>> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> > Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit
>>> /ffc6c8f6
>>> > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f
>>> fc6c8f6
>>> > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f
>>> fc6c8f6
>>> >
>>> > Branch: refs/heads/master
>>> > Commit: ffc6c8f68d260e8e14b140f0f05cbc77081efc2c
>>> > Parents: 0f1b0dc
>>> > Author: Gary Gregory <ggregory@apache.org>
>>> > Authored: Wed Aug 3 15:03:26 2016 -0700
>>> > Committer: Gary Gregory <ggregory@apache.org>
>>> > Committed: Wed Aug 3 15:03:26 2016 -0700
>>> >
>>> > ----------------------------------------------------------------------
>>> > .../log4j/core/impl/DefaultLogEventFactory.java |  5 ++
>>> > .../log4j/core/layout/AbstractStringLayout.java | 14 +--
>>> > .../logging/log4j/core/layout/JsonLayout.java   |  5 +-
>>> > .../logging/log4j/core/layout/YamlLayout.java   |  5 +-
>>> > .../log4j/core/layout/Log4j2_1482_CoreTest.java | 20 +++++
>>> > .../log4j/core/layout/Log4j2_1482_Test.java     | 89
>>> ++++++++++++++++++++
>>> > log4j-core/src/test/resources/log4j2-1482.xml   | 27 ++++++
>>> > log4j-slf4j-impl/pom.xml                        |  5 ++
>>> > .../logging/slf4j/Log4j2_1482_Slf4jTest.java    | 41 +++++++++
>>> > .../src/test/resources/log4j2-1482.xml          | 27 ++++++
>>> > src/changes/changes.xml                         |  3 +
>>> > 11 files changed, 231 insertions(+), 10 deletions(-)
>>> > ----------------------------------------------------------------------
>>> >
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/main/java/org/apache/logging/log4j/co
>>> re/impl/DefaultLogEventFactory.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/main/java/org
>>> /apache/logging/log4j/core/impl/DefaultLogEventFactory.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/imp
>>> l/DefaultLogEventFactory.java
>>> > index ef74c50..127b02a 100644
>>> > --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/imp
>>> l/DefaultLogEventFactory.java
>>> > +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/imp
>>> l/DefaultLogEventFactory.java
>>> > @@ -29,6 +29,11 @@ import org.apache.logging.log4j.message.Message;
>>> >  */
>>> > public class DefaultLogEventFactory implements LogEventFactory {
>>> >
>>> > +    private static final DefaultLogEventFactory instance = new
>>> DefaultLogEventFactory();
>>> > +
>>> > +    public static DefaultLogEventFactory getInstance() {
>>> > +        return instance;
>>> > +    }
>>> >
>>> >     /**
>>> >      * Creates a log event.
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/main/java/org/apache/logging/log4j/co
>>> re/layout/AbstractStringLayout.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/main/java/org
>>> /apache/logging/log4j/core/layout/AbstractStringLayout.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/AbstractStringLayout.java
>>> > index 9e6270e..5ac98e7 100644
>>> > --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/AbstractStringLayout.java
>>> > +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/AbstractStringLayout.java
>>> > @@ -20,6 +20,8 @@ import org.apache.logging.log4j.core.LogEvent;
>>> > import org.apache.logging.log4j.core.StringLayout;
>>> > import org.apache.logging.log4j.core.config.Configuration;
>>> > import org.apache.logging.log4j.core.config.LoggerConfig;
>>> > +import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
>>> > +import org.apache.logging.log4j.core.impl.LogEventFactory;
>>> > import org.apache.logging.log4j.core.util.Constants;
>>> > import org.apache.logging.log4j.core.util.StringEncoder;
>>> > import org.apache.logging.log4j.util.PropertiesUtil;
>>> > @@ -202,7 +204,7 @@ public abstract class AbstractStringLayout extends
>>> AbstractLayout<String> implem
>>> >      */
>>> >     @Override
>>> >     public byte[] getFooter() {
>>> > -        return serializeToBytes(footerSerializer, super.getFooter());
>>> > +        return serializeToBytes(footerSerializer, super.getFooter(),
>>> DefaultLogEventFactory.getInstance());
>>> >     }
>>> >
>>> >     public Serializer getFooterSerializer() {
>>> > @@ -216,28 +218,28 @@ public abstract class AbstractStringLayout
>>> extends AbstractLayout<String> implem
>>> >      */
>>> >     @Override
>>> >     public byte[] getHeader() {
>>> > -        return serializeToBytes(headerSerializer, super.getHeader());
>>> > +        return serializeToBytes(headerSerializer, super.getHeader(),
>>> DefaultLogEventFactory.getInstance());
>>> >     }
>>> >
>>> >     public Serializer getHeaderSerializer() {
>>> >         return headerSerializer;
>>> >     }
>>> >
>>> > -    protected byte[] serializeToBytes(final Serializer serializer,
>>> final byte[] defaultValue) {
>>> > -        final String serializable = serializeToString(serializer);
>>> > +    protected byte[] serializeToBytes(final Serializer serializer,
>>> final byte[] defaultValue, final LogEventFactory logEventFactory) {
>>> > +        final String serializable = serializeToString(serializer,
>>> logEventFactory);
>>> >         if (serializer == null) {
>>> >             return defaultValue;
>>> >         }
>>> >         return StringEncoder.toBytes(serializable, getCharset());
>>> >     }
>>> >
>>> > -    protected String serializeToString(final Serializer serializer) {
>>> > +    protected String serializeToString(final Serializer serializer,
>>> final LogEventFactory logEventFactory) {
>>> >         if (serializer == null) {
>>> >             return null;
>>> >         }
>>> >         final LoggerConfig rootLogger = getConfiguration().getRootLogg
>>> er();
>>> >         // Using "" for the FQCN, does it matter?
>>> > -        final LogEvent logEvent = rootLogger.getLogEventFactory(
>>> ).createEvent(rootLogger.getName(), null, Strings.EMPTY,
>>> > +        final LogEvent logEvent = logEventFactory.createEvent(rootLogger.getName(),
>>> null, Strings.EMPTY,
>>> >                 rootLogger.getLevel(), null, null, null);
>>> >         return serializer.toSerializable(logEvent);
>>> >     }
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/main/java/org/apache/logging/log4j/co
>>> re/layout/JsonLayout.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/main/java/org
>>> /apache/logging/log4j/core/layout/JsonLayout.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/JsonLayout.java
>>> > index e9d87ae..239a59f 100644
>>> > --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/JsonLayout.java
>>> > +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/JsonLayout.java
>>> > @@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.
>>> config.plugins.Plugin;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginConfigura
>>> tion;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginFactory;
>>> > +import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
>>> >
>>> > /**
>>> >  * Appends a series of JSON events as strings serialized as bytes.
>>> > @@ -828,7 +829,7 @@ public final class JsonLayout extends
>>> AbstractJacksonLayout {
>>> >             return null;
>>> >         }
>>> >         final StringBuilder buf = new StringBuilder();
>>> > -        final String str = serializeToString(getHeaderSerializer());
>>> > +        final String str = serializeToString(getHeaderSerializer(),
>>> DefaultLogEventFactory.getInstance());
>>> >         if (str != null) {
>>> >             buf.append(str);
>>> >         }
>>> > @@ -848,7 +849,7 @@ public final class JsonLayout extends
>>> AbstractJacksonLayout {
>>> >         }
>>> >         final StringBuilder buf = new StringBuilder();
>>> >         buf.append(this.eol);
>>> > -        final String str = serializeToString(getFooterSerializer());
>>> > +        final String str = serializeToString(getFooterSerializer(),
>>> DefaultLogEventFactory.getInstance());
>>> >         if (str != null) {
>>> >             buf.append(str);
>>> >         }
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/main/java/org/apache/logging/log4j/co
>>> re/layout/YamlLayout.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/main/java/org
>>> /apache/logging/log4j/core/layout/YamlLayout.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/YamlLayout.java
>>> > index 6f3e103..4b7a0c6 100644
>>> > --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/YamlLayout.java
>>> > +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lay
>>> out/YamlLayout.java
>>> > @@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.
>>> config.plugins.Plugin;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginConfigura
>>> tion;
>>> > import org.apache.logging.log4j.core.config.plugins.PluginFactory;
>>> > +import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
>>> > import org.apache.logging.log4j.util.Strings;
>>> >
>>> > /**
>>> > @@ -728,7 +729,7 @@ public final class YamlLayout extends
>>> AbstractJacksonLayout {
>>> >             return null;
>>> >         }
>>> >         final StringBuilder buf = new StringBuilder();
>>> > -        final String str = serializeToString(getHeaderSerializer());
>>> > +        final String str = serializeToString(getHeaderSerializer(),
>>> DefaultLogEventFactory.getInstance());
>>> >         if (str != null) {
>>> >             buf.append(str);
>>> >         }
>>> > @@ -748,7 +749,7 @@ public final class YamlLayout extends
>>> AbstractJacksonLayout {
>>> >         }
>>> >         final StringBuilder buf = new StringBuilder();
>>> >         buf.append(this.eol);
>>> > -        final String str = serializeToString(getFooterSerializer());
>>> > +        final String str = serializeToString(getFooterSerializer(),
>>> DefaultLogEventFactory.getInstance());
>>> >         if (str != null) {
>>> >             buf.append(str);
>>> >         }
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/test/java/org/apache/logging/log4j/co
>>> re/layout/Log4j2_1482_CoreTest.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/test/java/org
>>> /apache/logging/log4j/core/layout/Log4j2_1482_CoreTest.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/lay
>>> out/Log4j2_1482_CoreTest.java
>>> > new file mode 100644
>>> > index 0000000..24a38b6
>>> > --- /dev/null
>>> > +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lay
>>> out/Log4j2_1482_CoreTest.java
>>> > @@ -0,0 +1,20 @@
>>> > +package org.apache.logging.log4j.core.layout;
>>> > +
>>> > +import org.apache.logging.log4j.LogManager;
>>> > +import org.apache.logging.log4j.Logger;
>>> > +
>>> > +public class Log4j2_1482_CoreTest extends Log4j2_1482_Test {
>>> > +
>>> > +    @Override
>>> > +    protected void log(int runNumber) {
>>> > +        if (runNumber == 2) {
>>> > +            // System.out.println("Set a breakpoint here.");
>>> > +        }
>>> > +        final Logger logger = LogManager.getLogger("auditcsvfile");
>>> > +        final int val1 = 9, val2 = 11, val3 = 12;
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +    }
>>> > +
>>> > +}
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/test/java/org/apache/logging/log4j/co
>>> re/layout/Log4j2_1482_Test.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/test/java/org
>>> /apache/logging/log4j/core/layout/Log4j2_1482_Test.java
>>> b/log4j-core/src/test/java/org/apache/logging/log4j/core/lay
>>> out/Log4j2_1482_Test.java
>>> > new file mode 100644
>>> > index 0000000..d25a6ac
>>> > --- /dev/null
>>> > +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lay
>>> out/Log4j2_1482_Test.java
>>> > @@ -0,0 +1,89 @@
>>> > +/*
>>> > + * Licensed to the Apache Software Foundation (ASF) under one or more
>>> > + * contributor license agreements. See the NOTICE file distributed
>>> with
>>> > + * this work for additional information regarding copyright ownership.
>>> > + * The ASF licenses this file to You under the Apache license,
>>> Version 2.0
>>> > + * (the "License"); you may not use this file except in compliance
>>> with
>>> > + * the License. You may obtain a copy of the License at
>>> > + *
>>> > + *      http://www.apache.org/licenses/LICENSE-2.0
>>> > + *
>>> > + * Unless required by applicable law or agreed to in writing, software
>>> > + * distributed under the License is distributed on an "AS IS" BASIS,
>>> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> > + * See the license for the specific language governing permissions and
>>> > + * limitations under the license.
>>> > + */
>>> > +
>>> > +package org.apache.logging.log4j.core.layout;
>>> > +
>>> > +import java.io.File;
>>> > +import java.io.IOException;
>>> > +import java.nio.charset.Charset;
>>> > +import java.nio.file.Files;
>>> > +import java.nio.file.Path;
>>> > +import java.nio.file.Paths;
>>> > +import java.util.Arrays;
>>> > +import java.util.List;
>>> > +
>>> > +import org.apache.logging.log4j.core.LoggerContext;
>>> > +import org.apache.logging.log4j.core.config.Configurator;
>>> > +import org.apache.logging.log4j.junit.CleanFolders;
>>> > +import org.junit.Assert;
>>> > +import org.junit.Rule;
>>> > +import org.junit.Test;
>>> > +
>>> > +/**
>>> > + * Tests https://issues.apache.org/jira/browse/LOG4J2-1482
>>> > + */
>>> > +public abstract class Log4j2_1482_Test {
>>> > +
>>> > +    static final String CONFIG_LOCATION = "log4j2-1482.xml";
>>> > +
>>> > +    static final String FOLDER = "target/log4j2-1482";
>>> > +
>>> > +    private static final int LOOP_COUNT = 10;
>>> > +
>>> > +    static void assertFileContents(int runNumber) throws IOException {
>>> > +        Path path = Paths.get(FOLDER + "/audit.tmp");
>>> > +        List<String> lines = Files.readAllLines(path,
>>> Charset.defaultCharset());
>>> > +        int i = 1;
>>> > +        final int size = lines.size();
>>> > +        for (String string : lines) {
>>> > +            if (string.startsWith(",,")) {
>>> > +                Path folder = Paths.get(FOLDER);
>>> > +                File[] files = folder.toFile().listFiles();
>>> > +                Arrays.sort(files);
>>> > +                System.out.println("Run " + runNumber + ": " +
>>> Arrays.toString(files));
>>> > +                Assert.fail(
>>> > +                        String.format("Run %,d, line %,d of %,d:
>>> \"%s\" in %s", runNumber, i++, size, string, lines));
>>> > +            }
>>> > +        }
>>> > +    }
>>> > +
>>> > +    @Rule
>>> > +    public CleanFolders cleanFolders = new CleanFolders(FOLDER);
>>> > +
>>> > +    protected abstract void log(int runNumber) ;
>>> > +
>>> > +    private void loopingRun(int loopCount) throws IOException {
>>> > +        for (int i = 1; i <= loopCount; i++) {
>>> > +            try (LoggerContext loggerContext =
>>> Configurator.initialize(getClass().getName(),
>>> > +                    CONFIG_LOCATION)) {
>>> > +                log(i);
>>> > +            }
>>> > +            assertFileContents(i);
>>> > +        }
>>> > +    }
>>> > +
>>> > +    @Test
>>> > +    public void testLoopingRun() throws IOException {
>>> > +        loopingRun(LOOP_COUNT);
>>> > +    }
>>> > +
>>> > +    @Test
>>> > +    public void testSingleRun() throws IOException {
>>> > +        loopingRun(1);
>>> > +    }
>>> > +
>>> > +}
>>> > \ No newline at end of file
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-core/src/test/resources/log4j2-1482.xml
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-core/src/test/resources/log4j2-1482.xml
>>> b/log4j-core/src/test/resources/log4j2-1482.xml
>>> > new file mode 100644
>>> > index 0000000..e17953c
>>> > --- /dev/null
>>> > +++ b/log4j-core/src/test/resources/log4j2-1482.xml
>>> > @@ -0,0 +1,27 @@
>>> > +<?xml version="1.0" encoding="UTF-8"?>
>>> > +<Configuration status="warn" name="MyApp" packages="">
>>> > +  <Properties>
>>> > +    <Property name="audit-path">target/log4j2-1482</Property>
>>> > +    <Property name="file-name">audit</Property>
>>> > +    <Property name="file-header">param1,para
>>> m2,param3${sys:line.separator}
>>> > +    </Property>
>>> > +  </Properties>
>>> > +
>>> > +  <Appenders>
>>> > +    <RollingFile name="auditfile" fileName="${audit-path}/${file
>>> -name}.tmp"
>>> > +      filePattern="${audit-path}/${file-name}-%d{yyyy-MM-dd}-%i.csv">
>>> > +      <CsvParameterLayout delimiter="," header="${file-header}">
>>> > +      </CsvParameterLayout>
>>> > +      <Policies>
>>> > +        <SizeBasedTriggeringPolicy size="80 B" />
>>> > +      </Policies>
>>> > +      <DefaultRolloverStrategy max="2" />
>>> > +    </RollingFile>
>>> > +  </Appenders>
>>> > +
>>> > +  <Loggers>
>>> > +    <Root level="info">
>>> > +      <AppenderRef ref="auditfile" />
>>> > +    </Root>
>>> > +  </Loggers>
>>> > +</Configuration>
>>> > \ No newline at end of file
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-slf4j-impl/pom.xml
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-slf4j-impl/pom.xml b/log4j-slf4j-impl/pom.xml
>>> > index aca5799..21b02b1 100644
>>> > --- a/log4j-slf4j-impl/pom.xml
>>> > +++ b/log4j-slf4j-impl/pom.xml
>>> > @@ -58,6 +58,11 @@
>>> >       <scope>test</scope>
>>> >     </dependency>
>>> >     <dependency>
>>> > +      <groupId>org.apache.commons</groupId>
>>> > +      <artifactId>commons-csv</artifactId>
>>> > +      <scope>test</scope>
>>> > +    </dependency>
>>> > +    <dependency>
>>> >       <groupId>org.apache.logging.log4j</groupId>
>>> >       <artifactId>log4j-core</artifactId>
>>> >       <scope>test</scope>
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-slf4j-impl/src/test/java/org/apache/logging/sl
>>> f4j/Log4j2_1482_Slf4jTest.java
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-slf4j-impl/src/test/ja
>>> va/org/apache/logging/slf4j/Log4j2_1482_Slf4jTest.java
>>> b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Lo
>>> g4j2_1482_Slf4jTest.java
>>> > new file mode 100644
>>> > index 0000000..d621e76
>>> > --- /dev/null
>>> > +++ b/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/Lo
>>> g4j2_1482_Slf4jTest.java
>>> > @@ -0,0 +1,41 @@
>>> > +/*
>>> > + * Licensed to the Apache Software Foundation (ASF) under one or more
>>> > + * contributor license agreements. See the NOTICE file distributed
>>> with
>>> > + * this work for additional information regarding copyright ownership.
>>> > + * The ASF licenses this file to You under the Apache license,
>>> Version 2.0
>>> > + * (the "License"); you may not use this file except in compliance
>>> with
>>> > + * the License. You may obtain a copy of the License at
>>> > + *
>>> > + *      http://www.apache.org/licenses/LICENSE-2.0
>>> > + *
>>> > + * Unless required by applicable law or agreed to in writing, software
>>> > + * distributed under the License is distributed on an "AS IS" BASIS,
>>> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>>> implied.
>>> > + * See the license for the specific language governing permissions and
>>> > + * limitations under the license.
>>> > + */
>>> > +
>>> > +package org.apache.logging.slf4j;
>>> > +
>>> > +import org.apache.logging.log4j.core.layout.Log4j2_1482_Test;
>>> > +import org.slf4j.Logger;
>>> > +import org.slf4j.LoggerFactory;
>>> > +
>>> > +/**
>>> > + * Tests https://issues.apache.org/jira/browse/LOG4J2-1482
>>> > + */
>>> > +public class Log4j2_1482_Slf4jTest extends Log4j2_1482_Test {
>>> > +
>>> > +    @Override
>>> > +    protected void log(int runNumber) {
>>> > +        if (runNumber == 2) {
>>> > +            // System.out.println("Set a breakpoint here.");
>>> > +        }
>>> > +        final Logger logger = LoggerFactory.getLogger("audit
>>> csvfile");
>>> > +        final int val1 = 9, val2 = 11, val3 = 12;
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +        logger.info("Info Message!", val1, val2, val3);
>>> > +    }
>>> > +
>>> > +}
>>> > \ No newline at end of file
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
>>> > ----------------------------------------------------------------------
>>> > diff --git a/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
>>> b/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
>>> > new file mode 100644
>>> > index 0000000..e17953c
>>> > --- /dev/null
>>> > +++ b/log4j-slf4j-impl/src/test/resources/log4j2-1482.xml
>>> > @@ -0,0 +1,27 @@
>>> > +<?xml version="1.0" encoding="UTF-8"?>
>>> > +<Configuration status="warn" name="MyApp" packages="">
>>> > +  <Properties>
>>> > +    <Property name="audit-path">target/log4j2-1482</Property>
>>> > +    <Property name="file-name">audit</Property>
>>> > +    <Property name="file-header">param1,para
>>> m2,param3${sys:line.separator}
>>> > +    </Property>
>>> > +  </Properties>
>>> > +
>>> > +  <Appenders>
>>> > +    <RollingFile name="auditfile" fileName="${audit-path}/${file
>>> -name}.tmp"
>>> > +      filePattern="${audit-path}/${file-name}-%d{yyyy-MM-dd}-%i.csv">
>>> > +      <CsvParameterLayout delimiter="," header="${file-header}">
>>> > +      </CsvParameterLayout>
>>> > +      <Policies>
>>> > +        <SizeBasedTriggeringPolicy size="80 B" />
>>> > +      </Policies>
>>> > +      <DefaultRolloverStrategy max="2" />
>>> > +    </RollingFile>
>>> > +  </Appenders>
>>> > +
>>> > +  <Loggers>
>>> > +    <Root level="info">
>>> > +      <AppenderRef ref="auditfile" />
>>> > +    </Root>
>>> > +  </Loggers>
>>> > +</Configuration>
>>> > \ No newline at end of file
>>> >
>>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f
>>> fc6c8f6/src/changes/changes.xml
>>> > ----------------------------------------------------------------------
>>> > diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>>> > index b451094..31f280d 100644
>>> > --- a/src/changes/changes.xml
>>> > +++ b/src/changes/changes.xml
>>> > @@ -24,6 +24,9 @@
>>> >   </properties>
>>> >   <body>
>>> >     <release version="2.7" date="2016-MM-DD" description="GA Release
>>> 2.7">
>>> > +      <action issue="LOG4J2-1482" dev="ggregory" type="fix"
>>> due-to="Gary Gregory, Sumit Singhal">
>>> > +        Improper header in CsvParameterLayout.
>>> > +      </action>
>>> >       <action issue="LOG4J2-1199" dev="rpopma" type="fix">
>>> >         Document that JVM Input Arguments Lookup (JMX) is not
>>> available on Google App Engine.
>>> >       </action>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> 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
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message