You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/04 18:57:08 UTC

[1/5] git commit: Add IncompatibleLoggerException.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 501c6f1b7 -> 3faed6d42


Add IncompatibleLoggerException.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7f3bcce0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7f3bcce0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7f3bcce0

Branch: refs/heads/master
Commit: 7f3bcce08cbc87a319f653562543d69ccd5df2be
Parents: 657e5d5
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 11:25:51 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:49 2014 -0500

----------------------------------------------------------------------
 .../log4j/io/IncompatibleLoggerException.java   | 46 ++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3bcce0/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
new file mode 100644
index 0000000..dad13fc
--- /dev/null
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.io;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+
+/**
+ * Indicates that a provided {@link org.apache.logging.log4j.Logger} does not implement {@link ExtendedLogger}.
+ *
+ * @since 2.1
+ */
+public class IncompatibleLoggerException extends LoggingException {
+
+    private static final long serialVersionUID = 6861427446876787666L;
+
+    /**
+     * Constructs a new IncompatibleLoggerException using the type of the provided Logger. If {@code logger} is
+     * {@code null}, then the type is printed as "null". Note that this exception should only be thrown in situations
+     * where a Logger was provided but did not implement ExtendedLogger.
+     *
+     * @param logger the provided Logger that was not an ExtendedLogger
+     */
+    public IncompatibleLoggerException(final Logger logger) {
+        super(
+            "Incompatible Logger class. Expected to implement " + ExtendedLogger.class.getName() + ". Got: "
+                + (logger == null ? "null" : logger.getClass().getName())
+        );
+    }
+
+}


[3/5] git commit: Remove unused method.

Posted by ma...@apache.org.
Remove unused method.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/60fc53a8
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/60fc53a8
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/60fc53a8

Branch: refs/heads/master
Commit: 60fc53a8f83cdff235b20fbb94bd35aa94f7e968
Parents: 501c6f1
Author: Matt Sicker <ma...@apache.org>
Authored: Wed Sep 3 08:48:01 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:49 2014 -0500

----------------------------------------------------------------------
 .../apache/logging/log4j/io/AbstractStreamTest.java   | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/60fc53a8/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
index b0bdc27..8c3782e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
@@ -17,26 +17,20 @@
 
 package org.apache.logging.log4j.io;
 
-import static org.hamcrest.core.StringStartsWith.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
 import java.util.List;
 
 import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.apache.logging.log4j.spi.ExtendedLogger;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
 
+import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.Assert.*;
+
 public abstract class AbstractStreamTest {
-    
-    protected static Logger getLogger() {
-        return getExtendedLogger();
-    }
-    
+
     protected static ExtendedLogger getExtendedLogger() {
         return ctx.getLogger("UnitTestLogger");
     }


Re: [1/5] git commit: Add IncompatibleLoggerException.

Posted by Gary Gregory <ga...@gmail.com>.
I'd say reuse it as-is until there is a compelling use case for a custom
exception.

Gary


On Thu, Sep 4, 2014 at 1:11 PM, Matt Sicker <bo...@gmail.com> wrote:

> Extend UnsupportedOperationException? Or just throw that?
>
>
> On 4 September 2014 12:07, Gary Gregory <ga...@gmail.com> wrote:
>
>> What about calling it ExtendedLoggerException because
>> IncompatibleLoggerException begs the question, incompatible with what
>> purpose, feature, widget?
>>
>> We could also reuse UnsupportedOperationException.
>>
>> Gary
>>
>> ---------- Forwarded message ----------
>> From: <ma...@apache.org>
>> Date: Thu, Sep 4, 2014 at 12:57 PM
>> Subject: [1/5] git commit: Add IncompatibleLoggerException.
>> To: commits@logging.apache.org
>>
>>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 501c6f1b7 -> 3faed6d42
>>
>>
>> Add IncompatibleLoggerException.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7f3bcce0
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7f3bcce0
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7f3bcce0
>>
>> Branch: refs/heads/master
>> Commit: 7f3bcce08cbc87a319f653562543d69ccd5df2be
>> Parents: 657e5d5
>> Author: Matt Sicker <ma...@apache.org>
>> Authored: Thu Sep 4 11:25:51 2014 -0500
>> Committer: Matt Sicker <ma...@apache.org>
>> Committed: Thu Sep 4 11:56:49 2014 -0500
>>
>> ----------------------------------------------------------------------
>>  .../log4j/io/IncompatibleLoggerException.java   | 46 ++++++++++++++++++++
>>  1 file changed, 46 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3bcce0/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
>> b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
>> new file mode 100644
>> index 0000000..dad13fc
>> --- /dev/null
>> +++
>> b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
>> @@ -0,0 +1,46 @@
>> +/*
>> + * 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.io;
>> +
>> +import org.apache.logging.log4j.Logger;
>> +import org.apache.logging.log4j.LoggingException;
>> +import org.apache.logging.log4j.spi.ExtendedLogger;
>> +
>> +/**
>> + * Indicates that a provided {@link org.apache.logging.log4j.Logger}
>> does not implement {@link ExtendedLogger}.
>> + *
>> + * @since 2.1
>> + */
>> +public class IncompatibleLoggerException extends LoggingException {
>> +
>> +    private static final long serialVersionUID = 6861427446876787666L;
>> +
>> +    /**
>> +     * Constructs a new IncompatibleLoggerException using the type of
>> the provided Logger. If {@code logger} is
>> +     * {@code null}, then the type is printed as "null". Note that this
>> exception should only be thrown in situations
>> +     * where a Logger was provided but did not implement ExtendedLogger.
>> +     *
>> +     * @param logger the provided Logger that was not an ExtendedLogger
>> +     */
>> +    public IncompatibleLoggerException(final Logger logger) {
>> +        super(
>> +            "Incompatible Logger class. Expected to implement " +
>> ExtendedLogger.class.getName() + ". Got: "
>> +                + (logger == null ? "null" : logger.getClass().getName())
>> +        );
>> +    }
>> +
>> +}
>>
>>
>>
>>
>> --
>> 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
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
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

Re: [1/5] git commit: Add IncompatibleLoggerException.

Posted by Matt Sicker <bo...@gmail.com>.
Extend UnsupportedOperationException? Or just throw that?


On 4 September 2014 12:07, Gary Gregory <ga...@gmail.com> wrote:

> What about calling it ExtendedLoggerException because
> IncompatibleLoggerException begs the question, incompatible with what
> purpose, feature, widget?
>
> We could also reuse UnsupportedOperationException.
>
> Gary
>
> ---------- Forwarded message ----------
> From: <ma...@apache.org>
> Date: Thu, Sep 4, 2014 at 12:57 PM
> Subject: [1/5] git commit: Add IncompatibleLoggerException.
> To: commits@logging.apache.org
>
>
> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 501c6f1b7 -> 3faed6d42
>
>
> Add IncompatibleLoggerException.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7f3bcce0
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7f3bcce0
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7f3bcce0
>
> Branch: refs/heads/master
> Commit: 7f3bcce08cbc87a319f653562543d69ccd5df2be
> Parents: 657e5d5
> Author: Matt Sicker <ma...@apache.org>
> Authored: Thu Sep 4 11:25:51 2014 -0500
> Committer: Matt Sicker <ma...@apache.org>
> Committed: Thu Sep 4 11:56:49 2014 -0500
>
> ----------------------------------------------------------------------
>  .../log4j/io/IncompatibleLoggerException.java   | 46 ++++++++++++++++++++
>  1 file changed, 46 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3bcce0/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
> b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
> new file mode 100644
> index 0000000..dad13fc
> --- /dev/null
> +++
> b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
> @@ -0,0 +1,46 @@
> +/*
> + * 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.io;
> +
> +import org.apache.logging.log4j.Logger;
> +import org.apache.logging.log4j.LoggingException;
> +import org.apache.logging.log4j.spi.ExtendedLogger;
> +
> +/**
> + * Indicates that a provided {@link org.apache.logging.log4j.Logger} does
> not implement {@link ExtendedLogger}.
> + *
> + * @since 2.1
> + */
> +public class IncompatibleLoggerException extends LoggingException {
> +
> +    private static final long serialVersionUID = 6861427446876787666L;
> +
> +    /**
> +     * Constructs a new IncompatibleLoggerException using the type of the
> provided Logger. If {@code logger} is
> +     * {@code null}, then the type is printed as "null". Note that this
> exception should only be thrown in situations
> +     * where a Logger was provided but did not implement ExtendedLogger.
> +     *
> +     * @param logger the provided Logger that was not an ExtendedLogger
> +     */
> +    public IncompatibleLoggerException(final Logger logger) {
> +        super(
> +            "Incompatible Logger class. Expected to implement " +
> ExtendedLogger.class.getName() + ". Got: "
> +                + (logger == null ? "null" : logger.getClass().getName())
> +        );
> +    }
> +
> +}
>
>
>
>
> --
> 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
>



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

Fwd: [1/5] git commit: Add IncompatibleLoggerException.

Posted by Gary Gregory <ga...@gmail.com>.
What about calling it ExtendedLoggerException because
IncompatibleLoggerException begs the question, incompatible with what
purpose, feature, widget?

We could also reuse UnsupportedOperationException.

Gary

---------- Forwarded message ----------
From: <ma...@apache.org>
Date: Thu, Sep 4, 2014 at 12:57 PM
Subject: [1/5] git commit: Add IncompatibleLoggerException.
To: commits@logging.apache.org


Repository: logging-log4j2
Updated Branches:
  refs/heads/master 501c6f1b7 -> 3faed6d42


Add IncompatibleLoggerException.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7f3bcce0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7f3bcce0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7f3bcce0

Branch: refs/heads/master
Commit: 7f3bcce08cbc87a319f653562543d69ccd5df2be
Parents: 657e5d5
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 11:25:51 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:49 2014 -0500

----------------------------------------------------------------------
 .../log4j/io/IncompatibleLoggerException.java   | 46 ++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3bcce0/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
----------------------------------------------------------------------
diff --git
a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
new file mode 100644
index 0000000..dad13fc
--- /dev/null
+++
b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/IncompatibleLoggerException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.io;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LoggingException;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+
+/**
+ * Indicates that a provided {@link org.apache.logging.log4j.Logger} does
not implement {@link ExtendedLogger}.
+ *
+ * @since 2.1
+ */
+public class IncompatibleLoggerException extends LoggingException {
+
+    private static final long serialVersionUID = 6861427446876787666L;
+
+    /**
+     * Constructs a new IncompatibleLoggerException using the type of the
provided Logger. If {@code logger} is
+     * {@code null}, then the type is printed as "null". Note that this
exception should only be thrown in situations
+     * where a Logger was provided but did not implement ExtendedLogger.
+     *
+     * @param logger the provided Logger that was not an ExtendedLogger
+     */
+    public IncompatibleLoggerException(final Logger logger) {
+        super(
+            "Incompatible Logger class. Expected to implement " +
ExtendedLogger.class.getName() + ". Got: "
+                + (logger == null ? "null" : logger.getClass().getName())
+        );
+    }
+
+}




-- 
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

[2/5] git commit: Use default values in ctor.

Posted by ma...@apache.org.
Use default values in ctor.

  - Fall back to Logger.getLevel() for null Level.
  - Fall back to Charset.defaultCharset() for null Charset.
  - Inline ByteBufferInputStream instance.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/657e5d53
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/657e5d53
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/657e5d53

Branch: refs/heads/master
Commit: 657e5d5394f3d0a9aea3635753d090a4f650cc8a
Parents: c00b704
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 11:22:36 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:49 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/io/ByteStreamLogger.java   | 8 +++-----
 .../java/org/apache/logging/log4j/io/CharStreamLogger.java   | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/657e5d53/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java
index 42c4c63..8d3b3e3 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java
@@ -58,7 +58,6 @@ public class ByteStreamLogger {
     private final ExtendedLogger logger;
     private final Level level;
     private final Marker marker;
-    private final ByteBufferInputStream inputStream;
     private final InputStreamReader reader;
     private final char[] msgBuf = new char[BUFFER_SIZE];
     private final StringBuilder msg = new StringBuilder();
@@ -68,17 +67,16 @@ public class ByteStreamLogger {
 
     public ByteStreamLogger(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset) {
         this.logger = logger;
-        this.level = level;
+        this.level = level == null ? logger.getLevel() : level;
         this.marker = marker;
-        this.inputStream = new ByteBufferInputStream();
-        this.reader = new InputStreamReader(this.inputStream, charset);
+        this.reader = new InputStreamReader(new ByteBufferInputStream(),
+            charset == null ? Charset.defaultCharset() : charset);
     }
 
     public void close(final String fqcn) {
         synchronized (this.msg) {
             this.closed = true;
             logEnd(fqcn);
-//            in.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/657e5d53/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java
index f3977d8..cd7d92e 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java
@@ -32,7 +32,7 @@ public class CharStreamLogger {
 
     public CharStreamLogger(final ExtendedLogger logger, final Level level, final Marker marker) {
         this.logger = logger;
-        this.level = level;
+        this.level = level == null ? logger.getLevel() : level;
         this.marker = marker;
     }
 


[5/5] git commit: Refactor LoggerStream constructors into builder class.

Posted by ma...@apache.org.
Refactor LoggerStream constructors into builder class.

  - Now all the relevant classes can be constructed from a single unified builder class: LoggerStreams.
  - Removed a lot of constructors.
  - All constructors are now protected to allow for extension.
  - Updated tests to use builder.
  - Some documentation updated.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3faed6d4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3faed6d4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3faed6d4

Branch: refs/heads/master
Commit: 3faed6d42a6b87e068b431df5fcdf4066cc59a1d
Parents: 7f3bcce
Author: Matt Sicker <ma...@apache.org>
Authored: Thu Sep 4 11:56:30 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:50 2014 -0500

----------------------------------------------------------------------
 .../log4j/io/LoggerBufferedInputStream.java     |  51 +---
 .../logging/log4j/io/LoggerBufferedReader.java  |  26 +-
 .../log4j/io/LoggerFilterOutputStream.java      |  25 +-
 .../logging/log4j/io/LoggerFilterWriter.java    |  14 +-
 .../logging/log4j/io/LoggerInputStream.java     |  23 +-
 .../logging/log4j/io/LoggerOutputStream.java    |  22 +-
 .../logging/log4j/io/LoggerPrintStream.java     |  79 +-----
 .../logging/log4j/io/LoggerPrintWriter.java     |  46 +---
 .../apache/logging/log4j/io/LoggerReader.java   |  17 +-
 .../apache/logging/log4j/io/LoggerStreams.java  | 267 +++++++++++--------
 .../apache/logging/log4j/io/LoggerWriter.java   |  12 +-
 .../apache/logging/log4j/io/package-info.java   |  20 ++
 .../io/AbstractLoggerOutputStreamTest.java      |  18 +-
 .../log4j/io/AbstractLoggerWriterTest.java      |  18 +-
 ...LoggerBufferedInputStreamCallerInfoTest.java |  12 +-
 .../log4j/io/LoggerBufferedInputStreamTest.java |   6 +-
 .../io/LoggerBufferedReaderCallerInfoTest.java  |  10 +-
 .../log4j/io/LoggerBufferedReaderTest.java      |  13 +-
 .../log4j/io/LoggerFilterOutputStreamTest.java  |   5 +-
 .../log4j/io/LoggerFilterWriterTest.java        |   5 +-
 .../io/LoggerInputStreamCallerInfoTest.java     |   9 +-
 .../logging/log4j/io/LoggerInputStreamTest.java |  13 +-
 .../io/LoggerOutputStreamCallerInfoTest.java    |   6 +-
 .../log4j/io/LoggerOutputStreamTest.java        |   4 +-
 .../io/LoggerPrintStreamCallerInfoTest.java     |  12 +-
 .../logging/log4j/io/LoggerPrintStreamTest.java |  13 +-
 .../io/LoggerPrintWriterCallerInfoTest.java     |   7 +-
 .../logging/log4j/io/LoggerPrintWriterTest.java |  11 +-
 .../log4j/io/LoggerReaderCallerInfoTest.java    |   7 +-
 .../logging/log4j/io/LoggerReaderTest.java      |   9 +-
 .../logging/log4j/io/LoggerWriterTest.java      |   4 +-
 31 files changed, 358 insertions(+), 426 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
index 75dbb2f..0949f13 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java
@@ -29,54 +29,17 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
 public class LoggerBufferedInputStream extends BufferedInputStream {
     private static final String FQCN = LoggerBufferedInputStream.class.getName();
 
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level) {
-        this(in, charset, logger, FQCN, level, null);
+    protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
+                                        final String fqcn, final Level level, final Marker marker) {
+        super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker));
     }
 
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(in, charset, logger, FQCN, level, marker);
+    protected LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size,
+                                        final ExtendedLogger logger, final String fqcn, final Level level,
+                                        final Marker marker) {
+        super(new LoggerInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker), size);
     }
 
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerInputStream(in, charset, logger, fqcn, level, marker));
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level) {
-        this(in, charset, size, logger, FQCN, level, null);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(in, charset, size, logger, FQCN, level, marker);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerInputStream(in, charset, logger, fqcn, level, marker), size);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level) {
-        this(in, logger, FQCN, level, null);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(in, logger, FQCN, level, marker);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level) {
-        this(in, size, logger, FQCN, level, null);
-    }
-
-    public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(in, size, logger, FQCN, level, marker);
-    }
-    
-    public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        this(in, Charset.defaultCharset(), size, logger, fqcn, level, marker);
-    }
-    
     @Override
     public void close() throws IOException {
         super.close();

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
index 756f41a..9788f18 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java
@@ -29,28 +29,14 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
 public class LoggerBufferedReader extends BufferedReader {
     private static final String FQCN = LoggerBufferedReader.class.getName();
 
-    public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level) {
-        this(reader, logger, FQCN, level, null);
+    protected LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn,
+                                   final Level level, final Marker marker) {
+        super(new LoggerReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker));
     }
 
-    public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(reader, logger, FQCN, level, marker);
-    }
-
-    public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerReader(reader, logger, FQCN, level, marker));
-    }
-
-    public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level) {
-        this(reader, size, logger, FQCN, level, null);
-    }
-
-    public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(reader, size, logger, FQCN, level, marker);
-    }
-
-    public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerReader(reader, logger, FQCN, level, marker), size);
+    protected LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn,
+                                   final Level level, final Marker marker) {
+        super(new LoggerReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker), size);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
index d17544c..295c3e4 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java
@@ -38,30 +38,11 @@ public class LoggerFilterOutputStream extends FilterOutputStream {
     private final ByteStreamLogger logger;
     private final String fqcn;
 
-    public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
-            final Level level) {
-        this(out, charset, logger, FQCN, level, null);
-    }
-
-    public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
-            final Level level, final Marker marker) {
-        this(out, charset, logger, FQCN, level, marker);
-    }
-
-    public LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
-            final String fqcn, final Level level, final Marker marker) {
+    protected LoggerFilterOutputStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
+                                       final String fqcn, final Level level, final Marker marker) {
         super(out);
         this.logger = new ByteStreamLogger(logger, level, marker, charset);
-        this.fqcn = fqcn;
-    }
-
-    public LoggerFilterOutputStream(final OutputStream out, final ExtendedLogger logger, final Level level) {
-        this(out, Charset.defaultCharset(), logger, FQCN, level, null);
-    }
-
-    public LoggerFilterOutputStream(final OutputStream out, final ExtendedLogger logger, final Level level,
-            final Marker marker) {
-        this(out, Charset.defaultCharset(), logger, FQCN, level, marker);
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
index 5a9d8e0..c6b523d 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java
@@ -35,19 +35,11 @@ public class LoggerFilterWriter extends FilterWriter {
     private final CharStreamLogger logger;
     private final String fqcn;
 
-    public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final Level level) {
-        this(out, logger, FQCN, level, null);
-    }
-
-    public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(out, logger, FQCN, level, marker);
-    }
-
-    public LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level,
-            final Marker marker) {
+    protected LoggerFilterWriter(final Writer out, final ExtendedLogger logger, final String fqcn, final Level level,
+                                 final Marker marker) {
         super(out);
         this.logger = new CharStreamLogger(logger, level, marker);
-        this.fqcn = fqcn;
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
index 445e366..ff76b7f 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java
@@ -35,28 +35,11 @@ public class LoggerInputStream extends FilterInputStream {
     private final String fqcn;
     private final ByteStreamLogger logger;
 
-    public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level) {
-        this(in, charset, logger, FQCN, level, null);
-    }
-
-    public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level,
-            final Marker marker) {
-        this(in, charset, logger, FQCN, level, marker);
-    }
-
-    public LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
-            final String fqcn, final Level level, final Marker marker) {
+    protected LoggerInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger,
+                                final String fqcn, final Level level, final Marker marker) {
         super(in);
         this.logger = new ByteStreamLogger(logger, level, marker, charset);
-        this.fqcn = fqcn;
-    }
-
-    public LoggerInputStream(final InputStream in, final ExtendedLogger logger, final Level level) {
-        this(in, Charset.defaultCharset(), logger, FQCN, level, null);
-    }
-
-    public LoggerInputStream(final InputStream in, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(in, Charset.defaultCharset(), logger, FQCN, level, marker);
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
index 0d1829b..af8b2fe 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java
@@ -37,26 +37,10 @@ public class LoggerOutputStream extends OutputStream {
     private final ByteStreamLogger logger;
     private final String fqcn;
 
-    public LoggerOutputStream(final ExtendedLogger logger, final Level level) {
-        this(logger, level, null, Charset.defaultCharset(), FQCN);
-    }
-
-    public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Charset charset) {
-        this(logger, level, null, charset, FQCN);
-    }
-
-    public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(logger, level, marker, Charset.defaultCharset(), FQCN);
-    }
-
-    public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset) {
-        this(logger, level, marker, charset, FQCN);
-    }
-
-    public LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker,
-            final Charset charset, final String fqcn) {
+    protected LoggerOutputStream(final ExtendedLogger logger, final Level level, final Marker marker,
+                                 final Charset charset, final String fqcn) {
         this.logger = new ByteStreamLogger(logger, level, marker, charset);
-        this.fqcn = fqcn;
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
index f5d51a5..d51b492 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java
@@ -37,77 +37,22 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
 public class LoggerPrintStream extends PrintStream {
     private static final String FQCN = LoggerPrintStream.class.getName();
 
-    public LoggerPrintStream(final ExtendedLogger logger, final boolean autoFlush, final Charset charset,
-            final String fqcn, final Level level, final Marker marker) throws UnsupportedEncodingException {
-        super(new LoggerOutputStream(logger, level, marker, charset, fqcn), autoFlush, charset.name());
+    protected LoggerPrintStream(final ExtendedLogger logger, final boolean autoFlush, final Charset charset,
+                                final String fqcn, final Level level, final Marker marker)
+        throws UnsupportedEncodingException {
+        super(new LoggerOutputStream(logger, level, marker, ensureNonNull(charset), fqcn == null ? FQCN : fqcn),
+            autoFlush, ensureNonNull(charset).name());
     }
 
-    public LoggerPrintStream(final ExtendedLogger logger, final Level level) throws UnsupportedEncodingException {
-        this(logger, false, Charset.defaultCharset(), FQCN, level, null);
+    protected LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
+                                final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker)
+        throws UnsupportedEncodingException {
+        super(new LoggerFilterOutputStream(out, ensureNonNull(charset), logger, fqcn == null ? FQCN : fqcn, level,
+            marker), autoFlush, ensureNonNull(charset).name());
     }
 
-    public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Charset charset)
-            throws UnsupportedEncodingException {
-        this(logger, false, charset, FQCN, level, null);
-    }
-
-    public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Marker marker)
-            throws UnsupportedEncodingException {
-        this(logger, false, Charset.defaultCharset(), FQCN, level, marker);
-    }
-
-    public LoggerPrintStream(final ExtendedLogger logger, final Level level, final Marker marker, final Charset charset)
-            throws UnsupportedEncodingException {
-        this(logger, false, charset, FQCN, level, marker);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
-            final ExtendedLogger logger, final Level level) throws UnsupportedEncodingException {
-        this(out, autoFlush, charset, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
-            final ExtendedLogger logger, final Level level, final Marker marker) throws UnsupportedEncodingException {
-        this(out, autoFlush, charset, logger, FQCN, level, marker);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final Charset charset,
-            final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker)
-            throws UnsupportedEncodingException {
-        super(new LoggerFilterOutputStream(out, charset, logger, fqcn, level, marker), autoFlush, charset.name());
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
-            final Level level) {
-        this(out, autoFlush, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
-            final Level level, final Marker marker) {
-        this(out, autoFlush, logger, FQCN, level, marker);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final boolean autoFlush, final ExtendedLogger logger,
-            final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerFilterOutputStream(out, Charset.defaultCharset(), logger, fqcn, level, marker), autoFlush);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
-            final Level level) throws UnsupportedEncodingException {
-        this(out, false, charset, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final Charset charset, final ExtendedLogger logger,
-            final Level level, final Marker marker) throws UnsupportedEncodingException {
-        this(out, false, charset, logger, FQCN, level, marker);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final ExtendedLogger logger, final Level level) {
-        this(out, false, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintStream(final OutputStream out, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(out, false, logger, FQCN, level, marker);
+    private static Charset ensureNonNull(final Charset charset) {
+        return charset == null ? Charset.defaultCharset() : charset;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
index 500d255..6848463 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintWriter.java
@@ -31,7 +31,12 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
  * <p>
  * Integration with JDBC logging can be as simple as:
  * </p>
- * <pre>DriverManager.setLogWriter(new LoggerPrintWriter((ExtendedLogger) LogManager.getLogger(), Level.DEBUG));
+ * <pre>
+ *     Logger logger = LogManager.getLogger();
+ *     PrintWriter pw = LoggerStreams.forLogger(logger).setLevel(Level.DEBUG).buildPrintWriter();
+ *     DriverManager.setLogWriter(pw);
+ *     DataSource ds = ...
+ *     ds.setLogWriter(pw);
  * </pre>
  */
 // TODO 
@@ -40,41 +45,14 @@ import org.apache.logging.log4j.spi.ExtendedLogger;
 public class LoggerPrintWriter extends PrintWriter {
     private static final String FQCN = LoggerPrintWriter.class.getName();
 
-    @SuppressWarnings("resource")
-    public LoggerPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
-            final Level level, final Marker marker) {
-        super(new LoggerWriter(logger, fqcn, level, marker), autoFlush);
+    protected LoggerPrintWriter(final ExtendedLogger logger, final boolean autoFlush, final String fqcn,
+                                final Level level, final Marker marker) {
+        super(new LoggerWriter(logger, fqcn == null ? FQCN : fqcn, level, marker), autoFlush);
     }
 
-    public LoggerPrintWriter(final ExtendedLogger logger, final Level level) {
-        this(logger, false, FQCN, level, null);
-    }
-
-    public LoggerPrintWriter(final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(logger, false, FQCN, level, marker);
-    }
-
-    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger, final Level level) {
-        this(writer, autoFlush, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger, final Level level,
-            final Marker marker) {
-        this(writer, autoFlush, logger, FQCN, level, marker);
-    }
-
-    @SuppressWarnings("resource")
-    public LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
-            final String fqcn, final Level level, final Marker marker) {
-        super(new LoggerFilterWriter(writer, logger, fqcn, level, marker), autoFlush);
-    }
-
-    public LoggerPrintWriter(final Writer writer, final ExtendedLogger logger, final Level level) {
-        this(writer, false, logger, FQCN, level, null);
-    }
-
-    public LoggerPrintWriter(final Writer writer, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(writer, false, logger, FQCN, level, marker);
+    protected LoggerPrintWriter(final Writer writer, final boolean autoFlush, final ExtendedLogger logger,
+                                final String fqcn, final Level level, final Marker marker) {
+        super(new LoggerFilterWriter(writer, logger, fqcn == null ? FQCN : fqcn, level, marker), autoFlush);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
index 48427f8..652cb01 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java
@@ -27,8 +27,7 @@ import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.spi.ExtendedLogger;
 
 /**
- * Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface
- * that follows the {@link java.io.Writer} methods in spirit, but doesn't require output to any external writer.
+ * Logs each line read to a pre-defined level. Can also be configured with a Marker.
  */
 public class LoggerReader extends FilterReader {
     private static final String FQCN = LoggerReader.class.getName();
@@ -36,19 +35,11 @@ public class LoggerReader extends FilterReader {
     private final CharStreamLogger logger;
     private final String fqcn;
 
-    public LoggerReader(final Reader reader, final ExtendedLogger logger, final Level level) {
-        this(reader, logger, FQCN, level, null);
-    }
-
-    public LoggerReader(final Reader reader, final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(reader, logger, FQCN, level, marker);
-    }
-
-    public LoggerReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level,
-            final Marker marker) {
+    protected LoggerReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level,
+                           final Marker marker) {
         super(reader);
         this.logger = new CharStreamLogger(logger, level, marker);
-        this.fqcn = fqcn;
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
index 6378d19..20a2926 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerStreams.java
@@ -2,7 +2,7 @@
  * 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 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
  *
@@ -11,160 +11,213 @@
  * 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.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
  */
-
 package org.apache.logging.log4j.io;
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.nio.charset.Charset;
 
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LoggingException;
 import org.apache.logging.log4j.Marker;
 import org.apache.logging.log4j.spi.ExtendedLogger;
 
+/**
+ * Builder class to wrap {@link org.apache.logging.log4j.Logger Loggers} into Java IO compatible classes.
+ *
+ * @since 2.1
+ */
 public class LoggerStreams {
+    private final ExtendedLogger logger;
+    private Level level;
+    private Marker marker;
+    private String fqcn;
+    private boolean autoFlush;
+    private boolean buffered;
+    private int bufferSize;
+    private Charset charset;
+    private Reader reader;
+    private Writer writer;
+    private InputStream inputStream;
+    private OutputStream outputStream;
+
+    /**
+     * Creates a new builder for a given {@link Logger}. The Logger instance must implement {@link ExtendedLogger} or
+     * an exception will be thrown.
+     *
+     * @param logger the Logger to wrap into a LoggerStream
+     * @return a new LoggerStream builder
+     * @throws IncompatibleLoggerException if {@code logger} does not implement {@link ExtendedLogger} or if
+     *                                     {@code logger} is {@code null}
+     */
+    public static LoggerStreams forLogger(final Logger logger) {
+        return new LoggerStreams(logger);
+    }
 
-    public static class BufferedBuilder {
-        private final ExtendedLogger logger;
-        private final Level level;
-        private final Marker marker;
-        private final int size;
-
-        BufferedBuilder(final ExtendedLogger logger, final Level level, final Marker marker, final int size) {
-            this.logger = logger;
-            this.level = level;
-            this.marker = marker;
-            this.size = size;
-        }
-
-        public LoggerBufferedInputStream create(final InputStream in) {
-            if (this.size > 0) {
-                return new LoggerBufferedInputStream(in, this.size, this.logger, this.level, this.marker);
-            }
-            return new LoggerBufferedInputStream(in, this.logger, this.level, this.marker);
-        }
-
-        public LoggerBufferedInputStream create(final InputStream in, final Charset charset) {
-            if (this.size > 0) {
-                return new LoggerBufferedInputStream(in, charset, this.size, this.logger, this.level, this.marker);
-            }
-            return new LoggerBufferedInputStream(in, charset, this.logger, this.level, this.marker);
-        }
+    public static LoggerStreams forLogger(final String loggerName) {
+        return new LoggerStreams(LogManager.getLogger(loggerName));
+    }
 
-        public LoggerBufferedReader create(final Reader reader) {
-            if (this.size > 0) {
-                return new LoggerBufferedReader(reader, this.size, this.logger, this.level, this.marker);
-            }
-            return new LoggerBufferedReader(reader, this.logger, this.level, this.marker);
-        }
+    public static LoggerStreams forLogger(final Class<?> clazz) {
+        return new LoggerStreams(LogManager.getLogger(clazz));
+    }
 
-        public BufferedBuilder marker(final Marker marker) {
-            return new BufferedBuilder(this.logger, this.level, marker, this.size);
-        }
+    // TODO: arg-less factory (blocked by LOG4J2-809)
 
-        public BufferedBuilder size(final int size) {
-            return new BufferedBuilder(this.logger, this.level, this.marker, size);
+    private LoggerStreams(final Logger logger) {
+        if (!(logger instanceof ExtendedLogger)) {
+            throw new IncompatibleLoggerException(logger);
         }
+        this.logger = (ExtendedLogger) logger;
     }
 
-    public static class Builder {
-        private final ExtendedLogger logger;
-        private final Level level;
-        private final Marker marker;
+    public LoggerStreams setLevel(final Level level) {
+        this.level = level;
+        return this;
+    }
 
-        Builder(final ExtendedLogger logger, final Level level, final Marker marker) {
-            this.logger = logger;
-            this.level = level;
-            this.marker = marker;
-        }
+    public LoggerStreams setMarker(final Marker marker) {
+        this.marker = marker;
+        return this;
+    }
 
-        public BufferedBuilder buffered() {
-            return new BufferedBuilder(this.logger, this.level, this.marker, 0);
-        }
+    public LoggerStreams setWrapperClassName(final String fqcn) {
+        this.fqcn = fqcn;
+        return this;
+    }
 
-        public LoggerFilterWriter create(final Writer writer) {
-            return new LoggerFilterWriter(writer, this.logger, this.level, this.marker);
-        }
+    public LoggerStreams setAutoFlush(final boolean autoFlush) {
+        this.autoFlush = autoFlush;
+        return this;
+    }
 
-        public Builder marker(final Marker marker) {
-            return new Builder(this.logger, this.level, marker);
-        }
+    /**
+     * Enables or disables using a buffered variant of the desired IO class. If this is set to {@code true}, then the
+     * instances returned by {@link #buildReader()} and {@link #buildInputStream()} can be safely cast (if necessary)
+     * to {@link java.io.BufferedReader} and {@link java.io.BufferedInputStream} respectively. This option does not
+     * have any effect on the other built variants.
+     *
+     * @param buffered indicates whether or not an input LoggerStream should be buffered
+     * @return {@code this}
+     */
+    public LoggerStreams setBuffered(final boolean buffered) {
+        this.buffered = buffered;
+        return this;
+    }
 
-        public PrintingBuilder printing() {
-            return new PrintingBuilder(this.logger, this.level, this.marker, false);
-        }
+    public LoggerStreams setBufferSize(final int bufferSize) {
+        this.bufferSize = bufferSize;
+        return this;
     }
 
-    public static class PrintingBuilder {
-        private final ExtendedLogger logger;
-        private final Level level;
-        private final Marker marker;
-        private final boolean autoFlush;
+    public LoggerStreams setCharset(final Charset charset) {
+        this.charset = charset;
+        return this;
+    }
 
-        PrintingBuilder(final ExtendedLogger logger, final Level level, final Marker marker, final boolean autoFlush) {
-            this.logger = logger;
-            this.level = level;
-            this.marker = marker;
-            this.autoFlush = autoFlush;
-        }
+    public LoggerStreams filter(final Reader reader) {
+        this.reader = reader;
+        return this;
+    }
 
-        public PrintingBuilder autoFlush() {
-            return autoFlush(true);
-        }
+    public LoggerStreams filter(final Writer writer) {
+        this.writer = writer;
+        return this;
+    }
 
-        public PrintingBuilder autoFlush(final boolean autoFlush) {
-            return new PrintingBuilder(this.logger, this.level, this.marker, autoFlush);
-        }
+    public LoggerStreams filter(final InputStream inputStream) {
+        this.inputStream = inputStream;
+        return this;
+    }
 
-        public LoggerPrintStream create(final OutputStream out) {
-            return new LoggerPrintStream(out, this.autoFlush, this.logger, this.level, this.marker);
-        }
+    public LoggerStreams filter(final OutputStream outputStream) {
+        this.outputStream = outputStream;
+        return this;
+    }
 
-        public LoggerPrintStream create(final OutputStream out, final Charset charset) {
-            try {
-                return new LoggerPrintStream(out, this.autoFlush, charset, this.logger, this.level, this.marker);
-            } catch (final UnsupportedEncodingException e) {
-                // Should never occur because the constructor must throw this
-                throw new IllegalArgumentException("Invalid charset", e);
+    public Reader buildReader() {
+        final Reader r = requireNonNull(this.reader, "reader");
+        if (this.buffered) {
+            if (this.bufferSize > 0) {
+                return new LoggerBufferedReader(r, this.bufferSize, this.logger, this.fqcn, this.level, this.marker);
+            } else {
+                return new LoggerBufferedReader(r, this.logger, this.fqcn, this.level, this.marker);
             }
+        } else {
+            return new LoggerReader(requireNonNull(this.reader, "reader"), this.logger, this.fqcn, this.level,
+                this.marker);
         }
+    }
 
-        public LoggerPrintWriter create(final Writer writer) {
-            return new LoggerPrintWriter(writer, this.autoFlush, this.logger, this.level, this.marker);
-        }
-
-        public PrintingBuilder marker(final Marker marker) {
-            return new PrintingBuilder(this.logger, this.level, marker, this.autoFlush);
+    public Writer buildWriter() {
+        if (this.writer == null) {
+            return new LoggerWriter(this.logger, this.fqcn, this.level, this.marker);
+        } else {
+            return new LoggerFilterWriter(this.writer, this.logger, this.fqcn, this.level, this.marker);
         }
     }
 
-    public static Builder debug(final ExtendedLogger logger) {
-        return new Builder(logger, Level.DEBUG, null);
+    public PrintWriter buildPrintWriter() {
+        if (this.writer == null) {
+            return new LoggerPrintWriter(this.logger, this.autoFlush, this.fqcn, this.level, this.marker);
+        } else {
+            return new LoggerPrintWriter(this.writer, this.autoFlush, this.logger, this.fqcn, this.level, this.marker);
+        }
     }
 
-    public static Builder error(final ExtendedLogger logger) {
-        return new Builder(logger, Level.ERROR, null);
+    public InputStream buildInputStream() {
+        final InputStream i = requireNonNull(this.inputStream, "inputStream");
+        if (this.buffered) {
+            if (this.bufferSize > 0) {
+                return new LoggerBufferedInputStream(i, this.charset, this.bufferSize, this.logger, this.fqcn,
+                    this.level, this.marker);
+            } else {
+                return new LoggerBufferedInputStream(i, this.charset, this.logger, this.fqcn, this.level, this.marker);
+            }
+        }
+        return new LoggerInputStream(requireNonNull(this.inputStream, "inputStream"), this.charset, this.logger,
+            this.fqcn, this.level, this.marker);
     }
 
-    public static Builder fatal(final ExtendedLogger logger) {
-        return new Builder(logger, Level.FATAL, null);
+    public OutputStream buildOutputStream() {
+        if (this.outputStream == null) {
+            return new LoggerOutputStream(this.logger, this.level, this.marker, this.charset, this.fqcn);
+        } else {
+            return new LoggerFilterOutputStream(this.outputStream, this.charset, this.logger, this.fqcn, this.level,
+                this.marker);
+        }
     }
 
-    public static Builder info(final ExtendedLogger logger) {
-        return new Builder(logger, Level.INFO, null);
+    public PrintStream buildPrintStream() {
+        try {
+            if (this.outputStream == null) {
+                return new LoggerPrintStream(this.logger, this.autoFlush, this.charset, this.fqcn, this.level,
+                    this.marker);
+            } else {
+                return new LoggerPrintStream(this.outputStream, this.autoFlush, this.charset, this.logger, this.fqcn,
+                    this.level, this.marker);
+            }
+        } catch (final UnsupportedEncodingException e) {
+            // this exception shouldn't really happen since we use Charset and not String
+            throw new LoggingException(e);
+        }
     }
 
-    public static Builder trace(final ExtendedLogger logger) {
-        return new Builder(logger, Level.TRACE, null);
+    private static <T> T requireNonNull(final T obj, final String name) {
+        if (obj == null) {
+            throw new IllegalStateException("The property " + name + " was not set");
+        }
+        return obj;
     }
 
-    public static Builder warn(final ExtendedLogger logger) {
-        return new Builder(logger, Level.WARN, null);
-    }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
index 70310ad..b49cedf 100644
--- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java
@@ -34,17 +34,9 @@ public class LoggerWriter extends Writer {
     private final CharStreamLogger logger;
     private final String fqcn;
 
-    public LoggerWriter(final ExtendedLogger logger, final Level level) {
-        this(logger, FQCN, level, null);
-    }
-
-    public LoggerWriter(final ExtendedLogger logger, final Level level, final Marker marker) {
-        this(logger, FQCN, level, marker);
-    }
-
-    public LoggerWriter(final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
+    protected LoggerWriter(final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
         this.logger = new CharStreamLogger(logger, level, marker);
-        this.fqcn = fqcn;
+        this.fqcn = fqcn == null ? FQCN : fqcn;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
new file mode 100644
index 0000000..ea0d6ff
--- /dev/null
+++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+/**
+ * TODO: introduction to LoggerStreams
+ */
+package org.apache.logging.log4j.io;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
index a41b6dd..d0f82e2 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java
@@ -16,10 +16,6 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -28,6 +24,10 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.*;
+
 public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest {
     protected OutputStream out;
     protected ByteArrayOutputStream wrapped;
@@ -69,9 +69,13 @@ public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest
         out.close();
         replay(out);
 
-        final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
-        los.flush();
-        los.close();
+        final OutputStream filteredOut =
+            LoggerStreams.forLogger(getExtendedLogger())
+                .filter(out)
+                .setLevel(LEVEL)
+                .buildOutputStream();
+        filteredOut.flush();
+        filteredOut.close();
         verify(out);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
index 6fe81bc..9cc0fbb 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
@@ -16,10 +16,6 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.StringWriter;
@@ -29,6 +25,10 @@ import org.easymock.EasyMock;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.*;
+
 public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
     protected StringWriter wrapped;
     protected Writer writer;
@@ -70,9 +70,13 @@ public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
         out.close();
         replay(out);
 
-        final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
-        los.flush();
-        los.close();
+        final OutputStream filteredOut =
+            LoggerStreams.forLogger(getExtendedLogger())
+                .filter(out)
+                .setLevel(LEVEL)
+                .buildOutputStream();
+        filteredOut.flush();
+        filteredOut.close();
         verify(out);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
index 860f3b8..2822c89 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.io;
 
+import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
@@ -24,8 +25,8 @@ import org.junit.Test;
 
 public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    private LoggerBufferedInputStream logIn;
-    
+    private BufferedInputStream logIn;
+
     @Test
     public void close() throws Exception {
         this.logIn.read();
@@ -61,6 +62,11 @@ public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCaller
     @Before
     public void setupStreams() {
         final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
-        this.logIn = new LoggerBufferedInputStream(srcInputStream, getLogger(), LEVEL);
+        this.logIn = (BufferedInputStream)
+            LoggerStreams.forLogger(getLogger())
+                .filter(srcInputStream)
+                .setLevel(LEVEL)
+                .setBuffered(true)
+                .buildInputStream();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
index d2ba6b0..dc1add2 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
@@ -24,6 +24,10 @@ public class LoggerBufferedInputStreamTest extends LoggerInputStreamTest {
 
     @Override
     protected InputStream createInputStream() {
-        return new LoggerBufferedInputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(Level.ERROR)
+            .setBuffered(true)
+            .buildInputStream();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
index 2d9ff12..bd07f6d 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.io;
 
+import java.io.BufferedReader;
 import java.io.Reader;
 import java.io.StringReader;
 import java.nio.CharBuffer;
@@ -26,7 +27,7 @@ import org.junit.Test;
 
 public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    LoggerBufferedReader logReader;
+    BufferedReader logReader;
     
     @Test
     public void close() throws Exception {
@@ -79,6 +80,11 @@ public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoT
     @Before
     public void setupReader() {
         final Reader srcReader = new StringReader("a\nb\nc\nd");
-        this.logReader = new LoggerBufferedReader(srcReader, getLogger(), Level.WARN);
+        this.logReader = (BufferedReader)
+            LoggerStreams.forLogger(getLogger())
+                .filter(srcReader)
+                .setLevel(Level.WARN)
+                .setBuffered(true)
+                .buildReader();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
index 68e1811..88e5a03 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
@@ -16,19 +16,24 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-
 import java.io.BufferedReader;
 import java.io.Reader;
 
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class LoggerBufferedReaderTest extends LoggerReaderTest {
     private BufferedReader bufferedReader;
-    
+
     @Override
     protected Reader createReader() {
-        return this.bufferedReader = new LoggerBufferedReader(this.wrapped, getExtendedLogger(), LEVEL);
+        return this.bufferedReader = (BufferedReader)
+            LoggerStreams.forLogger(getExtendedLogger())
+                .filter(this.wrapped)
+                .setLevel(LEVEL)
+                .setBuffered(true)
+                .buildReader();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
index 60e48c5..95f637b 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
@@ -30,7 +30,10 @@ public class LoggerFilterOutputStreamTest extends AbstractLoggerOutputStreamTest
 
     @Override
     protected OutputStream createOutputStreamWrapper() {
-        return new LoggerFilterOutputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(Level.ERROR)
+            .buildOutputStream();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
index a58a51e..dbde900 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
@@ -12,7 +12,10 @@ public class LoggerFilterWriterTest extends AbstractLoggerWriterTest {
 
     @Override
     protected Writer createWriterWrapper() {
-        return new LoggerFilterWriter(this.wrapped, getExtendedLogger(), LEVEL);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(LEVEL)
+            .buildWriter();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
index bd812aa..690352e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
@@ -25,8 +25,8 @@ import org.junit.Test;
 
 public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    private LoggerInputStream logIn;
-    
+    private InputStream logIn;
+
     @Test
     public void read() throws Exception {
         this.logIn.read();
@@ -49,6 +49,9 @@ public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTest
     @Before
     public void setupStreams() {
         final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
-        this.logIn = new LoggerInputStream(srcInputStream, getLogger(), Level.WARN);
+        this.logIn = LoggerStreams.forLogger(getLogger())
+            .filter(srcInputStream)
+            .setLevel(Level.WARN)
+            .buildInputStream();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
index cd727a6..f0c6d48 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -27,13 +25,18 @@ import java.io.InputStream;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class LoggerInputStreamTest extends AbstractStreamTest {
     protected ByteArrayInputStream wrapped;
     protected ByteArrayOutputStream read;
     protected InputStream in;
 
     protected InputStream createInputStream() {
-        return new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(LEVEL)
+            .buildInputStream();
     }
 
     @Before
@@ -55,7 +58,7 @@ public class LoggerInputStreamTest extends AbstractStreamTest {
     @Test
     public void testClose_NoRemainingData() throws IOException {
         this.wrapped = new ByteArrayInputStream((FIRST + '\n').getBytes());
-        this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+        this.in = createInputStream();
 
         final byte[] bytes = new byte[1024];
         this.in.read(bytes);
@@ -116,7 +119,7 @@ public class LoggerInputStreamTest extends AbstractStreamTest {
     @Test
     public void testRead_MultipleLines() throws IOException {
         this.wrapped = new ByteArrayInputStream((FIRST + "\n" + LAST + '\n').getBytes());
-        this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+        this.in = createInputStream();
 
         final byte[] bytes = new byte[1024];
         final int len = this.in.read(bytes);

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
index c013fc6..cee3952 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
@@ -16,17 +16,19 @@
  */
 package org.apache.logging.log4j.io;
 
+import java.io.OutputStream;
+
 import org.apache.logging.log4j.Level;
 import org.junit.Before;
 import org.junit.Test;
 
 public class LoggerOutputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    private LoggerOutputStream logOut;
+    private OutputStream logOut;
     
     @Before
     public void setupStreams() {
-        this.logOut = new LoggerOutputStream(getExtendedLogger(), Level.WARN);
+        this.logOut = LoggerStreams.forLogger(getExtendedLogger()).setLevel(Level.WARN).buildOutputStream();
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
index 1631336..42f752c 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
@@ -30,7 +30,9 @@ public class LoggerOutputStreamTest extends AbstractLoggerOutputStreamTest {
 
     @Override
     protected OutputStream createOutputStreamWrapper() {
-        return new LoggerOutputStream(getExtendedLogger(), Level.ERROR);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .setLevel(Level.ERROR)
+            .buildOutputStream();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
index 2c533c3..84197e8 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.logging.log4j.io;
 
-import java.io.UnsupportedEncodingException;
+import java.io.PrintStream;
 import java.util.Locale;
 
 import org.apache.logging.log4j.Level;
@@ -25,8 +25,8 @@ import org.junit.Test;
 
 public class LoggerPrintStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    private LoggerPrintStream logOut;
-    
+    private PrintStream logOut;
+
     @Test
     public void close() throws Exception {
         this.logOut.print("a\nb");
@@ -120,8 +120,10 @@ public class LoggerPrintStreamCallerInfoTest extends LoggerStreamsCallerInfoTest
     }
     
     @Before
-    public void setupStreams() throws UnsupportedEncodingException {
-        this.logOut = new LoggerPrintStream(getLogger(), Level.WARN);
+    public void setupStreams() {
+        this.logOut = LoggerStreams.forLogger(getLogger())
+            .setLevel(Level.WARN)
+            .buildPrintStream();
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
index 38dd793..37cea4e 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
@@ -16,16 +16,16 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
+import java.io.PrintStream;
 
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class LoggerPrintStreamTest extends AbstractLoggerOutputStreamTest {
-    private LoggerPrintStream print;
+    private PrintStream print;
 
     @Override
     protected ByteArrayOutputStream createOutputStream() {
@@ -34,7 +34,10 @@ public class LoggerPrintStreamTest extends AbstractLoggerOutputStreamTest {
 
     @Override
     protected OutputStream createOutputStreamWrapper() {
-        return this.print = new LoggerPrintStream(this.wrapped, getExtendedLogger(), LEVEL);
+        return this.print = LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(LEVEL)
+            .buildPrintStream();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
index 7502040..416b44d 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.logging.log4j.io;
 
+import java.io.PrintWriter;
 import java.util.Locale;
 
 import org.apache.logging.log4j.Level;
@@ -24,7 +25,7 @@ import org.junit.Test;
 
 public class LoggerPrintWriterCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    private LoggerPrintWriter logOut;
+    private PrintWriter logOut;
     
     @Test
     public void close() throws Exception {
@@ -120,7 +121,9 @@ public class LoggerPrintWriterCallerInfoTest extends LoggerStreamsCallerInfoTest
     
     @Before
     public void setupStreams() {
-        this.logOut = new LoggerPrintWriter(getLogger(), Level.WARN);
+        this.logOut = LoggerStreams.forLogger(getLogger())
+            .setLevel(Level.WARN)
+            .buildPrintWriter();
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
index 7b13086..3559c75 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
@@ -16,15 +16,14 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.Writer;
 
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class LoggerPrintWriterTest extends AbstractLoggerWriterTest {
     private PrintWriter print; 
 
@@ -35,7 +34,11 @@ public class LoggerPrintWriterTest extends AbstractLoggerWriterTest {
 
     @Override
     protected Writer createWriterWrapper() {
-        this.print = new LoggerPrintWriter(this.wrapped, getExtendedLogger(), LEVEL);
+        this.print =
+            LoggerStreams.forLogger(getExtendedLogger())
+                .filter(this.wrapped)
+                .setLevel(LEVEL)
+                .buildPrintWriter();
         return this.print;
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
index 5e114e3..f084234 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 public class LoggerReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
 
-    LoggerReader logReader;
+    Reader logReader;
     
     @Test
     public void read() throws Exception {
@@ -52,6 +52,9 @@ public class LoggerReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
     @Before
     public void setupReader() {
         final Reader srcReader = new StringReader("a\nb\nc\nd\ne");
-        this.logReader = new LoggerReader(srcReader, getLogger(), LEVEL);
+        this.logReader = LoggerStreams.forLogger(getLogger())
+            .filter(srcReader)
+            .setLevel(LEVEL)
+            .buildReader();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
index 4f89d7b..10d715f 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
@@ -16,8 +16,6 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.Reader;
@@ -28,13 +26,18 @@ import java.nio.CharBuffer;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class LoggerReaderTest extends AbstractStreamTest {
     protected StringReader wrapped;
     protected StringWriter read;
     protected Reader reader;
 
     protected Reader createReader() {
-        return new LoggerReader(this.wrapped, getExtendedLogger(), LEVEL);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .filter(this.wrapped)
+            .setLevel(LEVEL)
+            .buildReader();
     }
     
     @Before

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3faed6d4/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
index 3d261be..0a302aa 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
@@ -28,7 +28,9 @@ public class LoggerWriterTest extends AbstractLoggerWriterTest {
 
     @Override
     protected Writer createWriterWrapper() {
-        return new LoggerWriter(getExtendedLogger(), LEVEL);
+        return LoggerStreams.forLogger(getExtendedLogger())
+            .setLevel(LEVEL)
+            .buildWriter();
     }
 
 }


[4/5] git commit: Use InitialLoggerContext.getListAppender().

Posted by ma...@apache.org.
Use InitialLoggerContext.getListAppender().


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c00b7046
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c00b7046
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c00b7046

Branch: refs/heads/master
Commit: c00b70466441c7c8cdb1cdba1afb7dc792bfc1d0
Parents: 60fc53a
Author: Matt Sicker <ma...@apache.org>
Authored: Wed Sep 3 08:49:24 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Thu Sep 4 11:56:49 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/io/AbstractStreamTest.java | 5 ++---
 .../logging/log4j/io/LoggerStreamsCallerInfoTesting.java     | 8 ++++----
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c00b7046/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
index 8c3782e..31fd4b9 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
@@ -22,7 +22,6 @@ import java.util.List;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
 
@@ -45,7 +44,7 @@ public abstract class AbstractStreamTest {
     public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-unit-test.xml");
 
     protected void assertMessages(final String... messages) {
-        final List<String> actualMsgs = ((ListAppender) ctx.getAppender("UnitTest")).getMessages();
+        final List<String> actualMsgs = ctx.getListAppender("UnitTest").getMessages();
         assertEquals("Unexpected number of results.", messages.length, actualMsgs.size());
         for (int i = 0; i < messages.length; i++) {
             final String start = LEVEL.name() + ' ' + messages[i];
@@ -55,6 +54,6 @@ public abstract class AbstractStreamTest {
 
     @Before
     public void clearAppender() {
-        ((ListAppender) ctx.getAppender("UnitTest")).clear();
+        ctx.getListAppender("UnitTest").clear();
     }
 }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c00b7046/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
index 8f050b3..58f6fa0 100644
--- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
@@ -16,8 +16,6 @@
  */
 package org.apache.logging.log4j.io;
 
-import static org.junit.Assert.assertEquals;
-
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
@@ -25,6 +23,8 @@ import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.Before;
 import org.junit.ClassRule;
 
+import static org.junit.Assert.*;
+
 public class LoggerStreamsCallerInfoTesting {
 
     protected static Logger getExtendedLogger() {
@@ -41,7 +41,7 @@ public class LoggerStreamsCallerInfoTesting {
     public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-calling-info.xml");
 
     public void assertMessages(final String msg, final int size, final String methodName) {
-        final ListAppender appender = (ListAppender) ctx.getAppender("ClassAndMethod");
+        final ListAppender appender = ctx.getListAppender("ClassAndMethod");
         assertEquals(msg + ".size", size, appender.getMessages().size());
         for (final String message : appender.getMessages()) {
             assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message);
@@ -50,6 +50,6 @@ public class LoggerStreamsCallerInfoTesting {
 
     @Before
     public void clearAppender() {
-        ((ListAppender) ctx.getAppender("ClassAndMethod")).clear();
+        ctx.getListAppender("ClassAndMethod").clear();
     }
 }