logback-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
February 2010
- 8 participants
- 103 discussions

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-42-g4097c6f
by git-noreply@pixie.qos.ch 22 Feb '10
by git-noreply@pixie.qos.ch 22 Feb '10
22 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 4097c6f76343e140bfc7ce11b73a95efceef0655 (commit)
from 96435c32e0541890f5bf3117baf160a5b0a1eb53 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=4097c6f76343e140bfc7ce11…
http://github.com/ceki/logback/commit/4097c6f76343e140bfc7ce11b73a95efceef0…
commit 4097c6f76343e140bfc7ce11b73a95efceef0655
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Feb 23 00:38:21 2010 +0100
typo fix
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
index 1be8dfc..7748701 100644
--- a/logback-site/src/site/pages/reasonsToSwitch.html
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -188,7 +188,7 @@ java.lang.Exception: 99 is invalid
</p>
<h3><a name="maxHistory" href="#maxHistory">Automatic erasure of
- old log arhives</a></h3>
+ old log archives</a></h3>
<p>By setting the <span class="option">MaxHistory</span> property
of <a
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/reasonsToSwitch.html | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-41-g96435c3
by git-noreply@pixie.qos.ch 22 Feb '10
by git-noreply@pixie.qos.ch 22 Feb '10
22 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 96435c32e0541890f5bf3117baf160a5b0a1eb53 (commit)
from e1d24597013b73981e1a1b1d3f518af7db808a58 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=96435c32e0541890f5bf3117…
http://github.com/ceki/logback/commit/96435c32e0541890f5bf3117baf160a5b0a1e…
commit 96435c32e0541890f5bf3117baf160a5b0a1eb53
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Feb 23 00:35:52 2010 +0100
more marketing...
diff --git a/logback-site/src/site/pages/index.html b/logback-site/src/site/pages/index.html
index 7fa648c..495c196 100644
--- a/logback-site/src/site/pages/index.html
+++ b/logback-site/src/site/pages/index.html
@@ -55,6 +55,26 @@
logback-core.
</p>
+
+ <h3>Select projects known to rely on logback</h3>
+
+ <ul>
+
+ <li><a href="http://www.jfrog.org/products.php">Artifactory</a></li>
+
+ <li><a href="http://code.google.com/p/openmeetings/">OpenMeetings</a></li>
+
+ <li><a href="http://liftweb.net/">Lift</a></li>
+
+ <li><a href="http://sonar.codehaus.org/">Sonar</a>
+ </li>
+
+ <li><a
+ href="http://static.springsource.org/s2-dmserver/2.0.x/user-guide/htmlsingle/user…">SpringSource
+ dm Server</a></li>
+
+
+
<script src="templates/footer.js" type="text/javascript"></script>
</div>
</body>
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
index 41b7153..1be8dfc 100644
--- a/logback-site/src/site/pages/reasonsToSwitch.html
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -188,7 +188,7 @@ java.lang.Exception: 99 is invalid
</p>
<h3><a name="maxHistory" href="#maxHistory">Automatic erasure of
- old log files</a></h3>
+ old log arhives</a></h3>
<p>By setting the <span class="option">MaxHistory</span> property
of <a
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/index.html | 20 ++++++++++++++++++++
logback-site/src/site/pages/reasonsToSwitch.html | 2 +-
2 files changed, 21 insertions(+), 1 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-40-ge1d2459
by git-noreply@pixie.qos.ch 22 Feb '10
by git-noreply@pixie.qos.ch 22 Feb '10
22 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via e1d24597013b73981e1a1b1d3f518af7db808a58 (commit)
from 576c1625cf8a8f431af78f0a90ba1d8bc7fb21bb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=e1d24597013b73981e1a1b1d…
http://github.com/ceki/logback/commit/e1d24597013b73981e1a1b1d3f518af7db808…
commit e1d24597013b73981e1a1b1d3f518af7db808a58
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon Feb 22 19:47:26 2010 +0100
- minor refactoring of the code, testing encoding with charsets...
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
index 91b29f6..2473580 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/AllClassicTest.java
@@ -30,6 +30,7 @@ import org.junit.runners.Suite.SuiteClasses;
ch.qos.logback.classic.html.PackageTest.class,
ch.qos.logback.classic.net.PackageTest.class,
ch.qos.logback.classic.pattern.PackageTest.class,
+ ch.qos.logback.classic.encoder.PackageTest.class,
ch.qos.logback.classic.db.PackageTest.class,
ch.qos.logback.classic.spi.PackageTest.class,
ch.qos.logback.classic.turbo.PackageTest.class,
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
similarity index 72%
copy from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
copy to logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
index 07c691c..b17a9ff 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PackageTest.java
@@ -11,15 +11,13 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.classic.encoder;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
- PropertySetterTest.class, NoAutoStartUtilTest.class,
- DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
+(a)SuiteClasses(PatternLayoutEncoderTest.class)
public class PackageTest {
-}
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
new file mode 100644
index 0000000..9a79884
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
@@ -0,0 +1,59 @@
+package ch.qos.logback.classic.encoder;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.LoggingEvent;
+
+public class PatternLayoutEncoderTest {
+
+ PatternLayoutEncoder ple = new PatternLayoutEncoder();
+ LoggerContext context = new LoggerContext();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ Logger logger = context.getLogger(PatternLayoutEncoderTest.class);
+ Charset utf8Charset = Charset.forName("UTF-8");
+
+ @Before
+ public void setUp() {
+ ple.setPattern("%m");
+ ple.setContext(context);
+ }
+
+ ILoggingEvent makeLoggingEvent(String message) {
+ return new LoggingEvent("", logger, Level.DEBUG, message, null, null);
+ }
+
+ @Test
+ public void smoke() throws IOException {
+ ple.start();
+ ple.init(baos);
+ String msg = "hello";
+ ILoggingEvent event = makeLoggingEvent(msg);
+ ple.doEncode(event);
+ ple.close();
+ assertEquals(msg, baos.toString());
+ }
+
+ @Test
+ public void charset() throws IOException {
+ ple.setCharset(utf8Charset);
+ ple.start();
+ ple.init(baos);
+ String msg = "\u03b1";
+ ILoggingEvent event = makeLoggingEvent(msg);
+ ple.doEncode(event);
+ ple.close();
+ assertEquals(msg, new String(baos.toByteArray(), utf8Charset));
+ }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
index bd1098e..0a168d9 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/ConsoleAppender.java
@@ -74,9 +74,9 @@ public class ConsoleAppender<E> extends WriterAppender<E> {
public void start() {
if (target.equals(SYSTEM_OUT)) {
- setWriter(System.out);
+ setOutputStream(System.out);
} else {
- setWriter(System.err);
+ setOutputStream(System.err);
}
super.start();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
index 72be15c..b392ba8 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
@@ -199,7 +199,7 @@ public class FileAppender<E> extends WriterAppender<E> {
// if (bufferedIO) {
// w = new BufferedWriter(w, bufferSize);
// }
- setWriter(resilientFos);
+ setOutputStream(resilientFos);
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
index e0410ed..94a2172 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
@@ -15,7 +15,6 @@ package ch.qos.logback.core;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.spi.DeferredProcessingAware;
@@ -32,8 +31,15 @@ import ch.qos.logback.core.status.ErrorStatus;
*/
public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
+ /**
+ * It is the encoder which is ultimately responsible for writing the event to
+ * an {@link OutputStream}.
+ */
protected Encoder<E> encoder;
+ /**
+ * All synchronization in this class is done via the lock object.
+ */
protected Object lock = new Object();
/**
@@ -51,15 +57,7 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
private boolean immediateFlush = true;
/**
- * The encoding to use when opening an InputStream.
- * <p>
- * The <code>encoding</code> variable is set to <code>null</null> by default
- * which results in the use of the system's default encoding.
- */
- private String encoding;
-
- /**
- * This is the {@link OutputStream outputStream} where we will write to.
+ * This is the {@link OutputStream outputStream} where output will be written.
*/
private OutputStream outputStream;
@@ -86,10 +84,15 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
immediateFlush = value;
}
- protected OutputStream getOutputStream() {
+ /**
+ * The underlying output stream used by this appender.
+ *
+ * @return
+ */
+ public OutputStream getOutputStream() {
return outputStream;
}
-
+
/**
* Returns value of the <b>ImmediateFlush</b> option.
*/
@@ -138,15 +141,15 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
*/
public void stop() {
synchronized (lock) {
- closeWriter();
+ closeOutputStream();
super.stop();
}
}
/**
- * Close the underlying {@link java.io.Writer}.
+ * Close the underlying {@link OutputStream}.
*/
- protected void closeWriter() {
+ protected void closeOutputStream() {
if (this.outputStream != null) {
try {
// before closing we have to output out layout's footer
@@ -154,43 +157,10 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
this.outputStream.close();
this.outputStream = null;
} catch (IOException e) {
- addStatus(new ErrorStatus("Could not close writer for WriterAppener.",
- this, e));
- }
- }
- }
-
- /**
- * Returns an OutputStreamWriter when passed an OutputStream. The encoding
- * used will depend on the value of the <code>encoding</code> property. If the
- * encoding value is specified incorrectly the writer will be opened using the
- * default system encoding (an error message will be printed to the loglog.
- */
- protected OutputStreamWriter createWriter(OutputStream os) {
- OutputStreamWriter retval = null;
-
- String enc = getEncoding();
- try {
- if (enc != null) {
- retval = new OutputStreamWriter(os, enc);
- } else {
- retval = new OutputStreamWriter(os);
- }
- } catch (IOException e) {
- addStatus(new ErrorStatus("Error initializing output writer.", this, e));
- if (enc != null) {
- addStatus(new ErrorStatus("Unsupported encoding?", this));
+ addStatus(new ErrorStatus(
+ "Could not close output stream for WriterAppener.", this, e));
}
}
- return retval;
- }
-
- public String getEncoding() {
- return encoding;
- }
-
- public void setEncoding(String value) {
- encoding = value;
}
void encoderInit() {
@@ -219,21 +189,22 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
/**
* <p>
- * Sets the Writer where the log output will go. The specified Writer must be
- * opened by the user and be writable. The <code>java.io.Writer</code> will be
- * closed when the appender instance is closed.
+ * Sets the @link OutputStream} where the log output will go. The specified
+ * <code>OutputStream</code> must be opened by the user and be writable. The
+ * <code>OutputStream</code> will be closed when the appender instance is
+ * closed.
*
- * @param writer
- * An already opened Writer.
+ * @param outputStream
+ * An already opened OutputStream.
*/
- public void setWriter(OutputStream outputStream) {
+ public void setOutputStream(OutputStream outputStream) {
synchronized (lock) {
- // close any previously opened writer
- closeWriter();
+ // close any previously opened output stream
+ closeOutputStream();
this.outputStream = outputStream;
if (encoder == null) {
- addWarn("Encoder not yet set. Cannot invoke init method ");
+ addWarn("Encoder not yet set. Cannot invoke it's init method");
return;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
index 3ed1ffa..038068b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/db/BindDataSourceToJNDIAction.java
@@ -22,7 +22,7 @@ import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
import ch.qos.logback.core.util.OptionHelper;
/**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
index cbbc966..caab0ce 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
@@ -2,6 +2,7 @@ package ch.qos.logback.core.html;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.charset.Charset;
import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.Layout;
@@ -11,6 +12,15 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
protected Layout<E> layout;
+ /**
+ * The charset to use when converting a String into bytes.
+ * <p>
+ * By default this property has the value
+ * <code>null</null> which corresponds to
+ * the system's default charset.
+ */
+ private Charset charset;
+
public Layout<E> getLayout() {
return layout;
}
@@ -19,22 +29,29 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
this.layout = layout;
}
+ public Charset getCharset() {
+ return charset;
+ }
+
+ /**
+ * Set the charset to use when converting the string returned by the layout
+ * into bytes.
+ * <p>
+ * By default this property has the value
+ * <code>null</null> which corresponds to
+ * the system's default charset.
+ *
+ * @param charset
+ */
+ public void setCharset(Charset charset) {
+ this.charset = charset;
+ }
public void init(OutputStream os) throws IOException {
super.init(os);
writeHeader();
}
- public void close() throws IOException {
- writeFooter();
- }
-
- private void appendIfNotNull(StringBuilder sb, String s) {
- if (s != null) {
- sb.append(s);
- }
- }
-
void writeHeader() throws IOException {
if (layout != null && (outputStream != null)) {
StringBuilder sb = new StringBuilder();
@@ -45,28 +62,40 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
// If at least one of file header or presentation header were not
// null, then append a line separator.
// This should be useful in most cases and should not hurt.
- outputStream.write(sb.toString().getBytes());
+ outputStream.write(convertToBytes(sb.toString()));
outputStream.flush();
}
}
}
+ public void close() throws IOException {
+ writeFooter();
+ }
+
void writeFooter() throws IOException {
if (layout != null && outputStream != null) {
StringBuilder sb = new StringBuilder();
appendIfNotNull(sb, layout.getPresentationFooter());
appendIfNotNull(sb, layout.getFileFooter());
if (sb.length() > 0) {
- outputStream.write(sb.toString().getBytes());
+ outputStream.write(convertToBytes(sb.toString()));
outputStream.flush();
}
}
}
+ private byte[] convertToBytes(String s) {
+ if (charset == null) {
+ return s.getBytes();
+ } else {
+ return s.getBytes(charset);
+ }
+ }
+
public void doEncode(E event) throws IOException {
String txt = layout.doLayout(event);
- outputStream.write(txt.getBytes());
+ outputStream.write(convertToBytes(txt));
outputStream.flush();
}
@@ -82,4 +111,10 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
started = false;
}
+ private void appendIfNotNull(StringBuilder sb, String s) {
+ if (s != null) {
+ sb.append(s);
+ }
+ }
+
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
index ba46eac..2a4728b 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForBasicProperty.java
@@ -13,7 +13,7 @@
*/
package ch.qos.logback.core.joran.action;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
import ch.qos.logback.core.util.AggregationType;
/**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
index e59b277..ad636f6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/IADataForComplexProperty.java
@@ -13,7 +13,7 @@
*/
package ch.qos.logback.core.joran.action;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
import ch.qos.logback.core.util.AggregationType;
/**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
index 28e6f1d..18907cd 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedBasicPropertyIA.java
@@ -19,7 +19,7 @@ import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
import ch.qos.logback.core.util.AggregationType;
/**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
index ceb5bbf..2f942c2 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/NestedComplexPropertyIA.java
@@ -20,7 +20,7 @@ import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.joran.spi.NoAutoStartUtil;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
import ch.qos.logback.core.spi.ContextAware;
import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.AggregationType;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
index af33532..924f6b7 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/ParamAction.java
@@ -17,7 +17,7 @@ package ch.qos.logback.core.joran.action;
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.InterpretationContext;
-import ch.qos.logback.core.joran.spi.PropertySetter;
+import ch.qos.logback.core.joran.util.PropertySetter;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
similarity index 74%
rename from logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java
rename to logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
index c0c69d5..246a0cb 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/PropertySetter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/PropertySetter.java
@@ -12,7 +12,7 @@
* as published by the Free Software Foundation.
*/
// Contributors: Georg Lundesgaard
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
@@ -21,10 +21,10 @@ import java.beans.MethodDescriptor;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
+import java.nio.charset.Charset;
-import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.joran.action.IADataForComplexProperty;
+import ch.qos.logback.core.joran.spi.DefaultClass;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.util.AggregationType;
import ch.qos.logback.core.util.PropertySetterException;
@@ -35,7 +35,8 @@ import ch.qos.logback.core.util.PropertySetterException;
* the Object specified in the constructor. This class relies on the JavaBeans
* {@link Introspector} to analyze the given Object Class using reflection.
*
- * <p> Usage:
+ * <p>
+ * Usage:
*
* <pre>
* PropertySetter ps = new PropertySetter(anObject);
@@ -52,7 +53,6 @@ import ch.qos.logback.core.util.PropertySetterException;
* @author Ceki Gulcu
*/
public class PropertySetter extends ContextAwareBase {
- private static final Class[] STING_CLASS_PARAMETER = new Class[] { String.class };
protected Object obj;
protected Class objClass;
@@ -64,7 +64,7 @@ public class PropertySetter extends ContextAwareBase {
* preparation for invoking {@link #setProperty} one or more times.
*
* @param obj
- * the object for which to set properties
+ * the object for which to set properties
*/
public PropertySetter(Object obj) {
this.obj = obj;
@@ -94,15 +94,16 @@ public class PropertySetter extends ContextAwareBase {
* setter argument type and partly from the value specified in the call to
* this method.
*
- * <p> If the setter expects a String no conversion is necessary. If it
- * expects an int, then an attempt is made to convert 'value' to an int using
- * new Integer(value). If the setter expects a boolean, the conversion is by
- * new Boolean(value).
+ * <p>
+ * If the setter expects a String no conversion is necessary. If it expects an
+ * int, then an attempt is made to convert 'value' to an int using new
+ * Integer(value). If the setter expects a boolean, the conversion is by new
+ * Boolean(value).
*
* @param name
- * name of the property
+ * name of the property
* @param value
- * String value of the property
+ * String value of the property
*/
public void setProperty(String name, String value) {
if (value == null) {
@@ -129,12 +130,12 @@ public class PropertySetter extends ContextAwareBase {
* Set the named property given a {@link PropertyDescriptor}.
*
* @param prop
- * A PropertyDescriptor describing the characteristics of the
- * property to set.
+ * A PropertyDescriptor describing the characteristics of the
+ * property to set.
* @param name
- * The named of the property to set.
+ * The named of the property to set.
* @param value
- * The value of the property.
+ * The value of the property.
*/
public void setProperty(PropertyDescriptor prop, String name, String value)
throws PropertySetterException {
@@ -154,7 +155,7 @@ public class PropertySetter extends ContextAwareBase {
Object arg;
try {
- arg = convertArg(value, paramTypes[0]);
+ arg = StringToObjectConverter.convertArg(this, value, paramTypes[0]);
} catch (Throwable t) {
throw new PropertySetterException("Conversion to type [" + paramTypes[0]
+ "] failed. ", t);
@@ -230,54 +231,19 @@ public class PropertySetter extends ContextAwareBase {
Class<?> parameterClass = getParameterClassForMethod(method);
if (parameterClass == null) {
return AggregationType.NOT_FOUND;
- } else {
- Package p = parameterClass.getPackage();
- if (parameterClass.isPrimitive()) {
- return AggregationType.AS_BASIC_PROPERTY;
- } else if (p != null && "java.lang".equals(p.getName())) {
- return AggregationType.AS_BASIC_PROPERTY;
- } else if (isBuildableFromString(parameterClass)) {
- return AggregationType.AS_BASIC_PROPERTY;
- } else if (parameterClass.isEnum()) {
- return AggregationType.AS_BASIC_PROPERTY;
- } else {
- return AggregationType.AS_COMPLEX_PROPERTY;
- }
}
- }
-
- public Class findUnequivocallyInstantiableClass(
- IADataForComplexProperty actionData) {
- Class<?> clazz;
- AggregationType at = actionData.getAggregationType();
- switch (at) {
- case AS_COMPLEX_PROPERTY:
- Method setterMethod = findSetterMethod(actionData
- .getComplexPropertyName());
- clazz = getParameterClassForMethod(setterMethod);
- if (clazz != null && isUnequivocallyInstantiable(clazz)) {
- return clazz;
- } else {
- return null;
- }
- case AS_COMPLEX_PROPERTY_COLLECTION:
- Method adderMethod = findAdderMethod(actionData.getComplexPropertyName());
- clazz = getParameterClassForMethod(adderMethod);
- if (clazz != null && isUnequivocallyInstantiable(clazz)) {
- return clazz;
- } else {
- return null;
- }
- default:
- throw new IllegalArgumentException(at
- + " is not valid type in this method");
+ if (StringToObjectConverter.canBeBuiltFromSimpleString(parameterClass)) {
+ return AggregationType.AS_BASIC_PROPERTY;
+ } else {
+ return AggregationType.AS_COMPLEX_PROPERTY;
}
}
/**
* Can the given clazz instantiable with certainty?
*
- * @param clazz The class to test for instantiability
+ * @param clazz
+ * The class to test for instantiability
* @return true if clazz can be instantiated, and false otherwise.
*/
private boolean isUnequivocallyInstantiable(Class<?> clazz) {
@@ -353,7 +319,7 @@ public class PropertySetter extends ContextAwareBase {
Object arg;
try {
- arg = convertArg(strValue, paramTypes[0]);
+ arg = StringToObjectConverter.convertArg(this, strValue, paramTypes[0]);
} catch (Throwable t) {
addError("Conversion to type [" + paramTypes[0] + "] failed. ", t);
return;
@@ -424,77 +390,8 @@ public class PropertySetter extends ContextAwareBase {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
- /**
- * Convert <code>val</code> a String parameter to an object of a given type.
- */
- protected Object convertArg(String val, Class<?> type) {
- if (val == null) {
- return null;
- }
- String v = val.trim();
- if (String.class.isAssignableFrom(type)) {
- return v;
- } else if (Integer.TYPE.isAssignableFrom(type)) {
- return new Integer(v);
- } else if (Long.TYPE.isAssignableFrom(type)) {
- return new Long(v);
- } else if (Float.TYPE.isAssignableFrom(type)) {
- return new Float(v);
- } else if (Double.TYPE.isAssignableFrom(type)) {
- return new Double(v);
- } else if (Boolean.TYPE.isAssignableFrom(type)) {
- if ("true".equalsIgnoreCase(v)) {
- return Boolean.TRUE;
- } else if ("false".equalsIgnoreCase(v)) {
- return Boolean.FALSE;
- }
- } else if (type.isEnum()) {
- return convertEnum(v, type);
- } else if (isBuildableFromString(type)) {
- return buildFromString(type, v);
- }
-
- return null;
- }
-
- boolean isBuildableFromString(Class<?> parameterClass) {
- try {
- Method valueOfMethod = parameterClass.getMethod(CoreConstants.VALUE_OF,
- STING_CLASS_PARAMETER);
- int mod = valueOfMethod.getModifiers();
- if (Modifier.isStatic(mod)) {
- return true;
- }
- } catch (SecurityException e) {
- // nop
- } catch (NoSuchMethodException e) {
- // nop
- }
- return false;
- }
-
- Object buildFromString(Class<?> type, String val) {
- try {
- Method valueOfMethod = type.getMethod(CoreConstants.VALUE_OF,
- STING_CLASS_PARAMETER);
- return valueOfMethod.invoke(null, val);
- } catch (Exception e) {
- addError("Failed to invoke " + CoreConstants.VALUE_OF
- + "{} method in class [" + type.getName() + "] with value [" + val
- + "]");
- return null;
- }
- }
-
- protected Object convertEnum(String val, Class<?> type) {
- try {
- Method m = type.getMethod(CoreConstants.VALUE_OF, STING_CLASS_PARAMETER);
- return m.invoke(null, val);
- } catch (Exception e) {
- addError("Failed to convert value [" + val + "] to enum ["
- + type.getName() + "]", e);
- }
- return null;
+ boolean isOfTypeCharset(Class<?> parameterClas) {
+ return Charset.class.isAssignableFrom(parameterClas);
}
protected Method getMethod(String methodName) {
@@ -566,14 +463,14 @@ public class PropertySetter extends ContextAwareBase {
}
Class getByConcreteType(String name, Method relevantMethod) {
-
+
Class<?> paramType = getParameterClassForMethod(relevantMethod);
if (paramType == null) {
return null;
}
-
+
boolean isUnequivocallyInstantiable = isUnequivocallyInstantiable(paramType);
- if(isUnequivocallyInstantiable) {
+ if (isUnequivocallyInstantiable) {
return paramType;
} else {
return null;
@@ -584,8 +481,9 @@ public class PropertySetter extends ContextAwareBase {
public Class getClassNameViaImplicitRules(String name,
AggregationType aggregationType, DefaultNestedComponentRegistry registry) {
- Class registryResult = registry.findDefaultComponentType(obj.getClass(), name);
- if(registryResult!= null) {
+ Class registryResult = registry.findDefaultComponentType(obj.getClass(),
+ name);
+ if (registryResult != null) {
return registryResult;
}
// find the relevant method for the given property name and aggregationType
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
new file mode 100644
index 0000000..8008f48
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
@@ -0,0 +1,135 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.joran.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
+
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.spi.ContextAware;
+
+/**
+ * Utility class which can convert string into objects.
+ * @author Ceki Gülcü
+ *
+ */
+public class StringToObjectConverter {
+
+ private static final Class[] STING_CLASS_PARAMETER = new Class[] { String.class };
+
+ static public boolean canBeBuiltFromSimpleString(Class<?> parameterClass) {
+ Package p = parameterClass.getPackage();
+ if (parameterClass.isPrimitive()) {
+ return true;
+ } else if (p != null && "java.lang".equals(p.getName())) {
+ return true;
+ } else if (followsTheValueOfConvention(parameterClass)) {
+ return true;
+ } else if (parameterClass.isEnum()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Convert <code>val</code> a String parameter to an object of a given type.
+ */
+ @SuppressWarnings("unchecked")
+ public static Object convertArg(ContextAware ca, String val, Class<?> type) {
+ if (val == null) {
+ return null;
+ }
+ String v = val.trim();
+ if (String.class.isAssignableFrom(type)) {
+ return v;
+ } else if (Integer.TYPE.isAssignableFrom(type)) {
+ return new Integer(v);
+ } else if (Long.TYPE.isAssignableFrom(type)) {
+ return new Long(v);
+ } else if (Float.TYPE.isAssignableFrom(type)) {
+ return new Float(v);
+ } else if (Double.TYPE.isAssignableFrom(type)) {
+ return new Double(v);
+ } else if (Boolean.TYPE.isAssignableFrom(type)) {
+ if ("true".equalsIgnoreCase(v)) {
+ return Boolean.TRUE;
+ } else if ("false".equalsIgnoreCase(v)) {
+ return Boolean.FALSE;
+ }
+ } else if (type.isEnum()) {
+ return convertToEnum(ca, v, (Class<? extends Enum>) type);
+ } else if (StringToObjectConverter.followsTheValueOfConvention(type)) {
+ return convertByValueOfMethod(ca, type, v);
+ } else if (isOfTypeCharset(type)) {
+ return convertToCharset(ca, val);
+ }
+
+ return null;
+ }
+
+ static private boolean isOfTypeCharset(Class<?> type) {
+ return Charset.class.isAssignableFrom(type);
+ }
+
+ static private Charset convertToCharset(ContextAware ca, String val) {
+ try {
+ return Charset.forName(val);
+ } catch (UnsupportedCharsetException e) {
+ ca.addError("Failed to get charset [" + val + "]", e);
+ return null;
+ }
+ }
+
+ static private boolean followsTheValueOfConvention(Class<?> parameterClass) {
+ try {
+ Method valueOfMethod = parameterClass.getMethod(CoreConstants.VALUE_OF,
+ STING_CLASS_PARAMETER);
+ int mod = valueOfMethod.getModifiers();
+ if (Modifier.isStatic(mod)) {
+ return true;
+ }
+ } catch (SecurityException e) {
+ // nop
+ } catch (NoSuchMethodException e) {
+ // nop
+ }
+ return false;
+ }
+
+ private static Object convertByValueOfMethod(ContextAware ca, Class<?> type,
+ String val) {
+ try {
+ Method valueOfMethod = type.getMethod(CoreConstants.VALUE_OF,
+ STING_CLASS_PARAMETER);
+ return valueOfMethod.invoke(null, val);
+ } catch (Exception e) {
+ ca.addError("Failed to invoke " + CoreConstants.VALUE_OF
+ + "{} method in class [" + type.getName() + "] with value [" + val
+ + "]");
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Object convertToEnum(ContextAware ca, String val,
+ Class<? extends Enum> enumType) {
+ return Enum.valueOf(enumType, val);
+ }
+
+ boolean isBuildableFromSimpleString() {
+ return false;
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
index 7008f42..215a7b3 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/RollingFileAppender.java
@@ -105,7 +105,7 @@ public class RollingFileAppender<E> extends FileAppender<E> {
//
// make sure to close the hereto active log file! Renaming under windows
// does not work for open files.
- this.closeWriter();
+ this.closeOutputStream();
try {
rollingPolicy.rollover();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
index e25d9d7..eea1422 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/WriterAppenderTest.java
@@ -101,7 +101,7 @@ public class WriterAppenderTest {
encoder.setContext(context);
wa.setEncoder(encoder);
- wa.setWriter(baos);
+ wa.setOutputStream(baos);
wa.start();
wa.stop();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
index ef132f8..9321161 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyWriterAppender.java
@@ -21,6 +21,6 @@ public class DummyWriterAppender<E> extends
WriterAppender<E> {
DummyWriterAppender(OutputStream os) {
- this.setWriter(os);
+ this.setOutputStream(os);
}
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
index a4d00d5..d65ac45 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/PackageTest.java
@@ -20,6 +20,7 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({SkippingInInterpreterTest.class, TrivialConfiguratorTest.class, ch.qos.logback.core.joran.action.PackageTest.class,
ch.qos.logback.core.joran.event.PackageTest.class,
+ ch.qos.logback.core.joran.util.PackageTest.class,
ch.qos.logback.core.joran.spi.PackageTest.class,
ch.qos.logback.core.joran.replay.PackageTest.class,
ch.qos.logback.core.joran.implicitAction.PackageTest.class
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
index fca70f4..68de22c 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/DefaultNestedComponentRegistryTest.java
@@ -16,10 +16,14 @@ package ch.qos.logback.core.joran.spi;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import java.awt.Window;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import ch.qos.logback.core.joran.util.House;
+
public class DefaultNestedComponentRegistryTest {
DefaultNestedComponentRegistry registry = new DefaultNestedComponentRegistry();
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
index 07c691c..92bd15a 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
@@ -19,7 +19,7 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
- PropertySetterTest.class, NoAutoStartUtilTest.class,
+ NoAutoStartUtilTest.class,
DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
public class PackageTest {
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
new file mode 100644
index 0000000..c2270b0
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
@@ -0,0 +1,158 @@
+package ch.qos.logback.core.joran.util;
+
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.joran.spi.DefaultClass;
+import ch.qos.logback.core.spi.FilterReply;
+import ch.qos.logback.core.util.Duration;
+import ch.qos.logback.core.util.FileSize;
+
+public class House {
+ Door mainDoor;
+ int count;
+ boolean open;
+ String name;
+ String camelCase;
+ SwimmingPool pool;
+ Duration duration;
+ FileSize fs;
+ HouseColor houseColor;
+ FilterReply reply;
+
+ Charset charset;
+
+ List<String> adjectiveList = new ArrayList<String>();
+ List<Window> windowList = new ArrayList<Window>();
+ List<SwimmingPool> largePoolList = new ArrayList<SwimmingPool>();
+
+ public String getCamelCase() {
+ return camelCase;
+ }
+
+ public void setCamelCase(String camelCase) {
+ this.camelCase = camelCase;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setCount(int c) {
+ this.count = c;
+ }
+
+ public Door getDoor() {
+ return mainDoor;
+ }
+
+ public void setDoor(Door door) {
+ this.mainDoor = door;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isOpen() {
+ return open;
+ }
+
+ public void setOpen(boolean open) {
+ this.open = open;
+ }
+
+ @DefaultClass(LargeSwimmingPoolImpl.class)
+ public void addLargeSwimmingPool(SwimmingPool pool) {
+ this.pool = pool;
+ }
+
+ @DefaultClass(SwimmingPoolImpl.class)
+ public void setSwimmingPool(SwimmingPool pool) {
+ this.pool = pool;
+ }
+
+ public SwimmingPool getSwimmingPool() {
+ return pool;
+ }
+
+ public void addWindow(Window w) {
+ windowList.add(w);
+ }
+
+ public void addAdjective(String s) {
+ adjectiveList.add(s);
+ }
+
+ public Duration getDuration() {
+ return duration;
+ }
+
+ public void setDuration(Duration duration) {
+ this.duration = duration;
+ }
+
+ public FileSize getFs() {
+ return fs;
+ }
+
+ public void setFs(FileSize fs) {
+ this.fs = fs;
+ }
+
+ public void setHouseColor(HouseColor color) {
+ this.houseColor = color;
+ }
+
+ public HouseColor getHouseColor() {
+ return houseColor;
+ }
+
+ public void setFilterReply(FilterReply reply) {
+ this.reply = reply;
+ }
+
+ public FilterReply getFilterReply() {
+ return reply;
+ }
+
+ public Charset getCharset() {
+ return charset;
+ }
+
+ public void setCharset(Charset charset) {
+ this.charset = charset;
+ }
+}
+
+class Door {
+ int handle;
+}
+
+class Window {
+ int handle;
+}
+
+interface SwimmingPool {
+}
+
+class SwimmingPoolImpl implements SwimmingPool {
+ int length;
+ int width;
+ int depth;
+}
+
+class LargeSwimmingPoolImpl implements SwimmingPool {
+ int length;
+ int width;
+ int depth;
+}
+
+enum HouseColor {
+ WHITE, BLUE
+}
\ No newline at end of file
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
similarity index 73%
copy from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
copy to logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
index 07c691c..feb3d0a 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PackageTest.java
@@ -11,15 +11,13 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses( { PatternTest.class, SimpleRuleStoreTest.class,
- PropertySetterTest.class, NoAutoStartUtilTest.class,
- DefaultNestedComponentRegistryTest.class, CaseCombinatorTest.class })
+@SuiteClasses( { StringToObjectConverterTest.class, PropertySetterTest.class })
public class PackageTest {
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
similarity index 65%
rename from logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
rename to logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
index 9436b87..0ac9396 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/joran/spi/PropertySetterTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/PropertySetterTest.java
@@ -11,33 +11,43 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.core.joran.spi;
+package ch.qos.logback.core.joran.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
+import java.nio.charset.Charset;
+import java.nio.charset.UnsupportedCharsetException;
+import org.junit.Before;
import org.junit.Test;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
+import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
import ch.qos.logback.core.spi.FilterReply;
+import ch.qos.logback.core.status.StatusChecker;
import ch.qos.logback.core.util.AggregationType;
-import ch.qos.logback.core.util.Duration;
-import ch.qos.logback.core.util.FileSize;
public class PropertySetterTest {
DefaultNestedComponentRegistry defaultComponentRegistry = new DefaultNestedComponentRegistry();
+ Context context = new ContextBase();
+ House house = new House();
+ PropertySetter setter = new PropertySetter(house);
+
+
+ @Before
+ public void setUp() {
+ setter.setContext(context);
+ }
+
@Test
public void testCanAggregateComponent() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
assertEquals(AggregationType.AS_COMPLEX_PROPERTY, setter
.computeAggregationType("door"));
@@ -103,9 +113,6 @@ public class PropertySetterTest {
@Test
public void testSetCamelProperty() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
-
setter.setProperty("camelCase", "trot");
assertEquals("trot", house.getCamelCase());
@@ -115,17 +122,13 @@ public class PropertySetterTest {
@Test
public void testSetComplexProperty() {
- House house = new House();
Door door = new Door();
- PropertySetter setter = new PropertySetter(house);
setter.setComplexProperty("door", door);
assertEquals(door, house.getDoor());
}
@Test
public void testgetClassNameViaImplicitRules() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
Class compClass = setter.getClassNameViaImplicitRules("door",
AggregationType.AS_COMPLEX_PROPERTY, defaultComponentRegistry);
assertEquals(Door.class, compClass);
@@ -133,8 +136,6 @@ public class PropertySetterTest {
@Test
public void testgetComplexPropertyColleClassNameViaImplicitRules() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
Class compClass = setter.getClassNameViaImplicitRules("window",
AggregationType.AS_COMPLEX_PROPERTY_COLLECTION,
defaultComponentRegistry);
@@ -143,10 +144,6 @@ public class PropertySetterTest {
@Test
public void testPropertyCollection() {
- House house = new House();
- Context context = new ContextBase();
- PropertySetter setter = new PropertySetter(house);
- setter.setContext(context);
setter.addBasicProperty("adjective", "nice");
setter.addBasicProperty("adjective", "big");
@@ -157,8 +154,6 @@ public class PropertySetterTest {
@Test
public void testComplexCollection() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
Window w1 = new Window();
w1.handle = 10;
Window w2 = new Window();
@@ -173,25 +168,19 @@ public class PropertySetterTest {
@Test
public void testSetComplexWithCamelCaseName() {
- House house = new House();
SwimmingPool pool = new SwimmingPoolImpl();
- PropertySetter setter = new PropertySetter(house);
setter.setComplexProperty("swimmingPool", pool);
assertEquals(pool, house.getSwimmingPool());
}
@Test
public void testDuration() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
setter.setProperty("duration", "1.4 seconds");
assertEquals(1400, house.getDuration().getMilliseconds());
}
@Test
public void testFileSize() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
setter.setProperty("fs", "2 kb");
assertEquals(2 * 1024, house.getFs().getSize());
}
@@ -199,24 +188,18 @@ public class PropertySetterTest {
@Test
public void testFilterReply() {
// test case reproducing bug #52
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
setter.setProperty("filterReply", "ACCEPT");
assertEquals(FilterReply.ACCEPT, house.getFilterReply());
}
@Test
public void testEnum() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
setter.setProperty("houseColor", "BLUE");
assertEquals(HouseColor.BLUE, house.getHouseColor());
}
@Test
public void testDefaultClassAnnonation() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
Method relevantMethod = setter.getRelevantMethod("SwimmingPool",
AggregationType.AS_COMPLEX_PROPERTY);
assertNotNull(relevantMethod);
@@ -232,8 +215,6 @@ public class PropertySetterTest {
@Test
public void testDefaultClassAnnotationForLists() {
- House house = new House();
- PropertySetter setter = new PropertySetter(house);
Method relevantMethod = setter.getRelevantMethod("LargeSwimmingPool",
AggregationType.AS_COMPLEX_PROPERTY_COLLECTION);
assertNotNull(relevantMethod);
@@ -245,145 +226,19 @@ public class PropertySetterTest {
"LargeSwimmingPool", AggregationType.AS_COMPLEX_PROPERTY_COLLECTION,
defaultComponentRegistry);
assertEquals(LargeSwimmingPoolImpl.class, classViaImplicitRules);
-
- }
-}
-
-class House {
- Door mainDoor;
- int count;
- boolean open;
- String name;
- String camelCase;
- SwimmingPool pool;
- Duration duration;
- FileSize fs;
- HouseColor houseColor;
- FilterReply reply;
-
- List<String> adjectiveList = new ArrayList<String>();
- List<Window> windowList = new ArrayList<Window>();
- List<SwimmingPool> largePoolList = new ArrayList<SwimmingPool>();
-
- public String getCamelCase() {
- return camelCase;
- }
-
- public void setCamelCase(String camelCase) {
- this.camelCase = camelCase;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setCount(int c) {
- this.count = c;
- }
-
- public Door getDoor() {
- return mainDoor;
- }
-
- public void setDoor(Door door) {
- this.mainDoor = door;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public boolean isOpen() {
- return open;
- }
-
- public void setOpen(boolean open) {
- this.open = open;
- }
-
- @DefaultClass(LargeSwimmingPoolImpl.class)
- public void addLargeSwimmingPool(SwimmingPool pool) {
- this.pool = pool;
- }
-
- @DefaultClass(SwimmingPoolImpl.class)
- public void setSwimmingPool(SwimmingPool pool) {
- this.pool = pool;
- }
-
- public SwimmingPool getSwimmingPool() {
- return pool;
- }
-
- public void addWindow(Window w) {
- windowList.add(w);
- }
-
- public void addAdjective(String s) {
- adjectiveList.add(s);
- }
-
- public Duration getDuration() {
- return duration;
- }
-
- public void setDuration(Duration duration) {
- this.duration = duration;
- }
-
- public FileSize getFs() {
- return fs;
- }
-
- public void setFs(FileSize fs) {
- this.fs = fs;
- }
-
- public void setHouseColor(HouseColor color) {
- this.houseColor = color;
- }
-
- public HouseColor getHouseColor() {
- return houseColor;
- }
-
- public void setFilterReply(FilterReply reply) {
- this.reply = reply;
}
+
+ @Test
+ public void charset() {
+ setter.setProperty("charset", "UTF-8");
+ assertEquals(Charset.forName("UTF-8"), house.getCharset());
+
+ house.setCharset(null);
+ setter.setProperty("charset", "UTF");
+ assertNull(house.getCharset());
- public FilterReply getFilterReply() {
- return reply;
+ StatusChecker checker = new StatusChecker(context);
+ checker.containsException(UnsupportedCharsetException.class);
}
-
-}
-
-class Door {
- int handle;
-}
-
-class Window {
- int handle;
-}
-
-interface SwimmingPool {
-}
-
-class SwimmingPoolImpl implements SwimmingPool {
- int length;
- int width;
- int depth;
-}
-
-class LargeSwimmingPoolImpl implements SwimmingPool {
- int length;
- int width;
- int depth;
}
-enum HouseColor {
- WHITE, BLUE
-}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java b/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java
new file mode 100644
index 0000000..48886ea
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.core.joran.util;
+
+import org.junit.Test;
+
+public class StringToObjectConverterTest {
+
+
+
+ @Test
+ public void doubleTest() {
+ fail("s");
+ }
+}
diff --git a/logback-examples/src/main/java/chapter4/ExitWoes1.java b/logback-examples/src/main/java/chapter4/ExitWoes1.java
index a265137..b14a36e 100644
--- a/logback-examples/src/main/java/chapter4/ExitWoes1.java
+++ b/logback-examples/src/main/java/chapter4/ExitWoes1.java
@@ -34,7 +34,7 @@ public class ExitWoes1 {
writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
OutputStream os = new FileOutputStream("exitWoes1.log");
- writerAppender.setWriter(os);
+ writerAppender.setOutputStream(os);
writerAppender.setImmediateFlush(false);
writerAppender.start();
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
diff --git a/logback-examples/src/main/java/chapter4/ExitWoes2.java b/logback-examples/src/main/java/chapter4/ExitWoes2.java
index ab2b89c..d95631a 100644
--- a/logback-examples/src/main/java/chapter4/ExitWoes2.java
+++ b/logback-examples/src/main/java/chapter4/ExitWoes2.java
@@ -35,7 +35,7 @@ public class ExitWoes2 {
writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
OutputStream os = new FileOutputStream("exitWoes2.log");
- writerAppender.setWriter(os);
+ writerAppender.setOutputStream(os);
writerAppender.setImmediateFlush(false);
writerAppender.start();
Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/classic/AllClassicTest.java | 1 +
.../classic/{control => encoder}/PackageTest.java | 5 +-
.../classic/encoder/PatternLayoutEncoderTest.java | 59 ++++++
.../java/ch/qos/logback/core/ConsoleAppender.java | 4 +-
.../java/ch/qos/logback/core/FileAppender.java | 2 +-
.../java/ch/qos/logback/core/WriterAppender.java | 89 +++------
.../core/db/BindDataSourceToJNDIAction.java | 2 +-
.../logback/core/html/LayoutWrappingEncoder.java | 61 +++++--
.../core/joran/action/IADataForBasicProperty.java | 2 +-
.../joran/action/IADataForComplexProperty.java | 2 +-
.../core/joran/action/NestedBasicPropertyIA.java | 2 +-
.../core/joran/action/NestedComplexPropertyIA.java | 2 +-
.../qos/logback/core/joran/action/ParamAction.java | 2 +-
.../core/joran/{spi => util}/PropertySetter.java | 170 ++++-------------
.../core/joran/util/StringToObjectConverter.java | 135 +++++++++++++
.../logback/core/rolling/RollingFileAppender.java | 2 +-
.../ch/qos/logback/core/WriterAppenderTest.java | 2 +-
.../logback/core/appender/DummyWriterAppender.java | 2 +-
.../ch/qos/logback/core/joran/PackageTest.java | 1 +
.../spi/DefaultNestedComponentRegistryTest.java | 4 +
.../ch/qos/logback/core/joran/spi/PackageTest.java | 2 +-
.../java/ch/qos/logback/core/joran/util/House.java | 158 +++++++++++++++
.../logback/core/{ => joran/util}/PackageTest.java | 4 +-
.../joran/{spi => util}/PropertySetterTest.java | 201 +++-----------------
.../joran/util/StringToObjectConverterTest.java | 13 ++
.../src/main/java/chapter4/ExitWoes1.java | 2 +-
.../src/main/java/chapter4/ExitWoes2.java | 2 +-
27 files changed, 530 insertions(+), 401 deletions(-)
copy logback-classic/src/test/java/ch/qos/logback/classic/{control => encoder}/PackageTest.java (87%)
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/encoder/PatternLayoutEncoderTest.java
rename logback-core/src/main/java/ch/qos/logback/core/joran/{spi => util}/PropertySetter.java (74%)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/joran/util/StringToObjectConverter.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/joran/util/House.java
copy logback-core/src/test/java/ch/qos/logback/core/{ => joran/util}/PackageTest.java (84%)
rename logback-core/src/test/java/ch/qos/logback/core/joran/{spi => util}/PropertySetterTest.java (65%)
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/joran/util/StringToObjectConverterTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-39-g576c162
by git-noreply@pixie.qos.ch 22 Feb '10
by git-noreply@pixie.qos.ch 22 Feb '10
22 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 576c1625cf8a8f431af78f0a90ba1d8bc7fb21bb (commit)
from 2d9abfae52400cf99ce88470cdf85fb45046b60e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=576c1625cf8a8f431af78f0a…
http://github.com/ceki/logback/commit/576c1625cf8a8f431af78f0a90ba1d8bc7fb2…
commit 576c1625cf8a8f431af78f0a90ba1d8bc7fb21bb
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon Feb 22 14:37:56 2010 +0100
mentioning packaging data in stack traces
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
index 26b0381..41b7153 100644
--- a/logback-site/src/site/pages/reasonsToSwitch.html
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -30,8 +30,8 @@
<p>Based on our previous work done on log4j, logback internals
have been re-written to perform about ten times faster on certain
- critical execution paths. Not only do logback components are
- faster, they have a smaller memory footprint as well.</p>
+ critical execution paths. Not only are logback components faster,
+ they have a smaller memory footprint as well.</p>
<h3><a name="tdd" href="#tdd">Extensive battery of tests</a></h3>
@@ -69,9 +69,9 @@
href="manual/configuration.html#autoScan">automatically reload its
configuration file upon modification</a>. The scanning process is
both fast and safe as it does <em>not</em> involve the creation of
- a separate scanning-thread. This technical subtlety ensures that
- logback plays well within application servers and more generally
- within the JEE environment.</p>
+ a separate thread for scanning. This technical subtlety ensures
+ that logback plays well within application servers and more
+ generally within the JEE environment.</p>
<h3><a name="lilith" href="#lilith">Lilith</a></h3>
@@ -90,8 +90,8 @@
<code>RollingFileAppender</code>.
</p>
- <p>Logback's <code>FileAppender</code> all its sub-classes
- including <code>RollingFileAppender</code> can gracefully recover
+ <p>Logback's <code>FileAppender</code> and all its sub-classes,
+ including <code>RollingFileAppender</code>, can gracefully recover
from I/O failures. Thus, if a file server fails temporarily, you
no longer need to restart your application just to repair logging.
</p>
@@ -103,30 +103,30 @@
href="manual/filters.html">filtering capabilities</a> going much
further than what log4j has to offer. For example, let's assume
that you have a business-critical application deployed on a
- production server. Given the large volume of transactions,
- logging level is set to WARN so that only warnings and errors are
- logged. Now imagine that you are confronted with a bug that can be
- reproduced on the production system but remains elusive on the
- test platform due to unspecified differences between the two
- environments (production/testing).
+ production server. Given the large volume of transactions
+ processed, logging level is set to WARN so that only warnings and
+ errors are logged. Now imagine that you are confronted with a bug
+ that can be reproduced on the production system but remains
+ elusive on the test platform due to unspecified differences
+ between those two environments (production/testing).
</p>
<p>With log4j, your only choice is to lower the logging level to
DEBUG on the production system in an attempt to identify the
problem. Unfortunately, this will generate large volume of logging
data, making analysis difficult. More importantly, extensive
- logging can impact the performance of you application on the
+ logging can impact the performance of your application on the
production system.</p>
<p>With logback, you have the option of keeping logging at the
WARN level for all users except for the one user, say Alice, who
is responsible for identifying the problem. When Alice is logged
- on, she will be logging at level DEBUG while for other users
- logging will remain at WARN. This feat can be accomplished by
- adding 4 lines of XML to your configuration file. Search for
+ on, she will be logging at level DEBUG while other users can
+ continue to log at the WARN level. This feat can be accomplished
+ by adding 4 lines of XML to your configuration file. Search for
<code>MDCFilter</code> in the <a
- href="manual/filters.html#TurboFilter">relevant section</a> of
- the manual.
+ href="manual/filters.html#TurboFilter">relevant section</a> of the
+ manual.
</p>
@@ -135,7 +135,7 @@
<p><a
href="manual/appenders.html#SiftingAppender">SiftingAppender</a>
is an amazingly versatile appender. It can be used to separate (or
- sift) logging according to any given runtime attribute. For
+ sift) logging according to <b>any</b> given runtime attribute. For
example, <code>SiftingAppender</code> can separate logging events
according to user sessions, so that the logs generated by each
user go into distinct log files, one log file per user.
@@ -144,14 +144,50 @@
<h3><a name="compression" href="#compression">Automatic
compression of archives log files</a></h3>
- <p><a href="manual/appenders.html#RollingFileAppender">RollingFileAppender</a> can automatically
- compression archived log files during rollover. Compression always
- occurs asynchronously so that even for large log files your
- application is not blocked for the duration of the compression.
+ <p><a
+ href="manual/appenders.html#RollingFileAppender">RollingFileAppender</a>
+ can automatically compress archived log files during
+ rollover. Compression always occurs asynchronously so that even
+ for large log files, your application is not blocked for the
+ duration of the compression.
</p>
- <h3><a name="maxHistory" href="#maxHistory">Automatic erasing of
+ <h3><a name="packagingData" href="#packagingData">Stack traces
+ with packaging data</a>
+ </h3>
+
+ <p>When logback prints an exception, the stack trace will include
+ packaging data. Here is a sample stack trace generated by the <a
+ href="demo.html">logback-demo</a> web-application.</p>
+
+ <pre>14:28:48.835 [btpool0-7] INFO c.q.l.demo.prime.PrimeAction - 99 is not a valid value
+java.lang.Exception: 99 is invalid
+ at ch.qos.logback.demo.prime.PrimeAction.execute(PrimeAction.java:28) [classes/:na]
+ at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) [struts-1.2.9.jar:1.2.9]
+ at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) [struts-1.2.9.jar:1.2.9]
+ at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) [struts-1.2.9.jar:1.2.9]
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) [servlet-api-2.5-6.1.12.jar:6.1.12]
+ at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502) [jetty-6.1.12.jar:6.1.12]
+ at ch.qos.logback.demo.UserServletFilter.doFilter(UserServletFilter.java:44) [classes/:na]
+ at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115) [jetty-6.1.12.jar:6.1.12]
+ at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361) [jetty-6.1.12.jar:6.1.12]
+ at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417) [jetty-6.1.12.jar:6.1.12]
+ at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230) [jetty-6.1.12.jar:6.1.12]</pre>
+
+ <p>From the above, you can recognize that the applicaiton is using
+ Struts version 1.2.9 and was deployed under jetty version
+ 6.1.12. Thus, stack traces will quickly inform the reader about
+ the classes invervening in the exception but also the package and
+ package versions they belong to. When your customers send you a
+ stack trace, as a developper you will no longer need to ask them
+ to send you information about the versions of packages they are
+ using. The information will be part of the stack trace. See <a
+ href="manual/layouts.html#conversionWord">"%xThrowable" conversion
+ word</a> for details.
+ </p>
+
+ <h3><a name="maxHistory" href="#maxHistory">Automatic erasure of
old log files</a></h3>
<p>By setting the <span class="option">MaxHistory</span> property
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/reasonsToSwitch.html | 86 +++++++++++++++------
1 files changed, 61 insertions(+), 25 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-38-g2d9abfa
by git-noreply@pixie.qos.ch 22 Feb '10
by git-noreply@pixie.qos.ch 22 Feb '10
22 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 2d9abfae52400cf99ce88470cdf85fb45046b60e (commit)
from 8270ffa0f18e65c70d176d30b71cf748845e0441 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2d9abfae52400cf99ce88470…
http://github.com/ceki/logback/commit/2d9abfae52400cf99ce88470cdf85fb45046b…
commit 2d9abfae52400cf99ce88470cdf85fb45046b60e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon Feb 22 12:54:48 2010 +0100
- marketing...
diff --git a/logback-site/src/site/pages/documentation.html b/logback-site/src/site/pages/documentation.html
index 7dbcef3..29f4e95 100644
--- a/logback-site/src/site/pages/documentation.html
+++ b/logback-site/src/site/pages/documentation.html
@@ -28,6 +28,9 @@
<ul>
<li><a href="manual/index.html"><b>The logback manual</b></a></li>
+ <li><a href="reasonsToSwitch.html">Reasons to switch to logback
+ from log4j</a></li>
+
<li>
<a href="access.html">An introduction to logback-access for Jetty
and Tomcat</a>
diff --git a/logback-site/src/site/pages/index.html b/logback-site/src/site/pages/index.html
index b5293b9..7fa648c 100644
--- a/logback-site/src/site/pages/index.html
+++ b/logback-site/src/site/pages/index.html
@@ -22,7 +22,8 @@
<h2>Logback Project</h2>
<p>Logback is intended as a successor to the popular log4j
- project, picking up where log4j left off.
+ project, <a href="reasonsToSwitch.html">picking up where log4j
+ left off</a>.
</p>
<p>Logback's basic architecture is sufficiently generic so as to
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 9a273c6..fa89892 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -3384,8 +3384,7 @@ logger.error(<b>notifyAdminMarker</b>,
attribute. For example, <code>SiftingAppender</code> can separate
logging events according to user sessions, so that the logs
generated by every user go into distinct log files, one log file
- per user. For example, <code>SiftingAppender</code> can separate
- logging events into distinct log files, one file per user.
+ per user.
</p>
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
new file mode 100644
index 0000000..26b0381
--- /dev/null
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -0,0 +1,180 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <title>Reasons to prefer logback</title>
+ <link rel="stylesheet" type="text/css" href="css/common.css" />
+ <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen" />
+ <link rel="stylesheet" type="text/css" href="css/_print.css" media="print" />
+
+ </head>
+ <body>
+ <script type="text/javascript">prefix='';</script>
+ <script src="templates/header.js" type="text/javascript"></script>
+ <div id="left">
+ <noscript>Please turn on Javascript to view this menu</noscript>
+ <script src="templates/left.js" type="text/javascript"></script>
+ </div>
+ <div id="content">
+
+ <h2>Reasons to prefer logback over log4j</h2>
+
+ <p>Here is a non-exhaustive list of reasons for switching to
+ logback from log4j. Keep in mind that logback is conceptually very
+ similar to log4j. If you are already familiar with log4j, you will
+ quickly feel at home using logback.</p>
+
+ <h3><a name="fasterImpl" href="#fasterImpl">Faster implementation</a></h3>
+
+ <p>Based on our previous work done on log4j, logback internals
+ have been re-written to perform about ten times faster on certain
+ critical execution paths. Not only do logback components are
+ faster, they have a smaller memory footprint as well.</p>
+
+ <h3><a name="tdd" href="#tdd">Extensive battery of tests</a></h3>
+
+ <p>Logback comes with a very extensive battery of tests developed
+ over the course of several years and untold hours of work. While
+ log4j is also tested, logback takes testing to a completely
+ different level. In our opinion, this is the single most important
+ reason to prefer logback over log4j. You want your logging
+ framework to be rock solid and dependable even under adverse
+ conditions.
+ </p>
+
+ <h3><a name="slf4j" href="#slf4j">logback-classic speaks SLF4J
+ natively</a></h3>
+
+ <p>Since the <code>Logger</code> class in logback-classic
+ implements the SLF4J API natively, you incur zero overhead when
+ invoking an SLF4J logger with logback-classic as the underlying
+ implementation. Moreover, since logback-classic strongly
+ encourages the use of SLF4J as its client API, if you need to
+ switch to log4j or to j.u.l., you can do so by replacing one jar
+ file with another. You will not need to touch your code logging
+ via the SLF4J API. This can drastically reduce the work involved
+ in switching logging frameworks.
+ </p>
+
+ <h3><a name="docs" href="#docs">Extensive documentation</a></h3>
+
+ <p>Logback ships with over two hundred pages of documentation.</p>
+
+ <h3><a name="autoScan" href="#autoScan">Automatic reloading of
+ configuration files</a></h3>
+
+ <p>Logback-classic can <a
+ href="manual/configuration.html#autoScan">automatically reload its
+ configuration file upon modification</a>. The scanning process is
+ both fast and safe as it does <em>not</em> involve the creation of
+ a separate scanning-thread. This technical subtlety ensures that
+ logback plays well within application servers and more generally
+ within the JEE environment.</p>
+
+
+ <h3><a name="lilith" href="#lilith">Lilith</a></h3>
+
+ <p><a href="http://lilith.huxhorn.de/">Lilith</a> is a logging and
+ access event viewer for logback. It is comparable to log4j's
+ chainsaw, except that Lilith is designed to handle large amounts of
+ logging data without flinching.</p>
+
+ <h3><a name="grace" href="#grace">Prudent mode and graceful recovery</a></h3>
+
+ <p>In <a href="manual/appenders.html#prudent">prudent mode</a>,
+ multiple <code>FileAppender</code> instances running on multiple
+ JVMs can safely write to the same log file. With certain
+ limitations, prudent mode extends to
+ <code>RollingFileAppender</code>.
+ </p>
+
+ <p>Logback's <code>FileAppender</code> all its sub-classes
+ including <code>RollingFileAppender</code> can gracefully recover
+ from I/O failures. Thus, if a file server fails temporarily, you
+ no longer need to restart your application just to repair logging.
+ </p>
+
+
+ <h3><a name="filters" href="#filters">Filters</a></h3>
+
+ <p>Logback comes with a wide array of <a
+ href="manual/filters.html">filtering capabilities</a> going much
+ further than what log4j has to offer. For example, let's assume
+ that you have a business-critical application deployed on a
+ production server. Given the large volume of transactions,
+ logging level is set to WARN so that only warnings and errors are
+ logged. Now imagine that you are confronted with a bug that can be
+ reproduced on the production system but remains elusive on the
+ test platform due to unspecified differences between the two
+ environments (production/testing).
+ </p>
+
+ <p>With log4j, your only choice is to lower the logging level to
+ DEBUG on the production system in an attempt to identify the
+ problem. Unfortunately, this will generate large volume of logging
+ data, making analysis difficult. More importantly, extensive
+ logging can impact the performance of you application on the
+ production system.</p>
+
+ <p>With logback, you have the option of keeping logging at the
+ WARN level for all users except for the one user, say Alice, who
+ is responsible for identifying the problem. When Alice is logged
+ on, she will be logging at level DEBUG while for other users
+ logging will remain at WARN. This feat can be accomplished by
+ adding 4 lines of XML to your configuration file. Search for
+ <code>MDCFilter</code> in the <a
+ href="manual/filters.html#TurboFilter">relevant section</a> of
+ the manual.
+ </p>
+
+
+ <h3><a name="sift" href="#sift">SiftingAppender</a></h3>
+
+ <p><a
+ href="manual/appenders.html#SiftingAppender">SiftingAppender</a>
+ is an amazingly versatile appender. It can be used to separate (or
+ sift) logging according to any given runtime attribute. For
+ example, <code>SiftingAppender</code> can separate logging events
+ according to user sessions, so that the logs generated by each
+ user go into distinct log files, one log file per user.
+ </p>
+
+ <h3><a name="compression" href="#compression">Automatic
+ compression of archives log files</a></h3>
+
+ <p><a href="manual/appenders.html#RollingFileAppender">RollingFileAppender</a> can automatically
+ compression archived log files during rollover. Compression always
+ occurs asynchronously so that even for large log files your
+ application is not blocked for the duration of the compression.
+ </p>
+
+
+ <h3><a name="maxHistory" href="#maxHistory">Automatic erasing of
+ old log files</a></h3>
+
+ <p>By setting the <span class="option">MaxHistory</span> property
+ of <a
+ href="manual/appenders.html#TimeBasedRollingPolicy">TimeBasedRollingPolicy</a>
+ or <a
+ href="manual/appenders.html#SizeAndTimeBasedFNATP">SizeAndTimeBasedFNATP</a>,
+ you can control the maximum number of archived files. If your
+ rolling policy calls for monthly rollover and you wish to keep 1
+ year's worth of logs, simply set the <span
+ class="option">MaxHistory</span> property to 12. Archived log
+ files older than 12 months will be automatically removed.
+ </p>
+
+
+ <h3><a href="">In summary</a></h3>
+
+ <p>We have listed a small number of reasons for preferring logback
+ over log4j. Given that logback builds upon the log4j experience,
+ to put it simply, logback is just a better log4j.</p>
+
+ <script src="templates/footer.js" type="text/javascript"></script>
+ </div>
+
+ </body>
+</html>
\ No newline at end of file
diff --git a/logback-site/src/site/pages/templates/footer.js b/logback-site/src/site/pages/templates/footer.js
index f97c725..c548cab 100644
--- a/logback-site/src/site/pages/templates/footer.js
+++ b/logback-site/src/site/pages/templates/footer.js
@@ -1,6 +1,10 @@
document.write('<table class="footer">')
+
+
+document.write('</tr>')
+
document.write('<tr>')
document.write(' <td>')
@@ -10,8 +14,13 @@ document.write(' ')
//document.write(' alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>')
document.write(' </td>')
-document.write('<td valign="top">Copyright © 1999-2010 <a href="http://www.qos.ch/">QOS.ch</a></td>')
-
+document.write('<td valign="top">Copyright © 2010 <a href="http://www.qos.ch/">QOS.ch</a></td>')
document.write('</tr>')
+
+document.write('<tr>')
+document.write('<td align="left" colspan="2">')
+document.write('We are actively looking for volunteers to proofread the documentation. Please send your corrections or suggestions for improvement to "corrections(a)qos.ch".');
+document.write('</td>')
+
document.write('</table>')
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/documentation.html | 3 +
logback-site/src/site/pages/index.html | 3 +-
logback-site/src/site/pages/manual/appenders.html | 3 +-
logback-site/src/site/pages/reasonsToSwitch.html | 180 +++++++++++++++++++++
logback-site/src/site/pages/templates/footer.js | 13 ++-
5 files changed, 197 insertions(+), 5 deletions(-)
create mode 100644 logback-site/src/site/pages/reasonsToSwitch.html
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-37-g8270ffa
by git-noreply@pixie.qos.ch 21 Feb '10
by git-noreply@pixie.qos.ch 21 Feb '10
21 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 8270ffa0f18e65c70d176d30b71cf748845e0441 (commit)
from b90d74bcaadef20e47ac469d51fee1d1367ca57f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=8270ffa0f18e65c70d176d30…
http://github.com/ceki/logback/commit/8270ffa0f18e65c70d176d30b71cf748845e0…
commit 8270ffa0f18e65c70d176d30b71cf748845e0441
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sun Feb 21 23:30:47 2010 +0100
- a more general description of logback omitting Ceki as founder of
both projects.
diff --git a/logback-site/src/site/pages/index.html b/logback-site/src/site/pages/index.html
index 5be9939..b5293b9 100644
--- a/logback-site/src/site/pages/index.html
+++ b/logback-site/src/site/pages/index.html
@@ -22,10 +22,7 @@
<h2>Logback Project</h2>
<p>Logback is intended as a successor to the popular log4j
- project. It was designed, in addition to many individual
- contributors, by Ceki Gülcü, the founder of log4j. It
- builds upon experience gained in building industrial-strength
- logging systems going back as far as 1999.
+ project, picking up where log4j left off.
</p>
<p>Logback's basic architecture is sufficiently generic so as to
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/index.html | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-36-gb90d74b
by git-noreply@pixie.qos.ch 21 Feb '10
by git-noreply@pixie.qos.ch 21 Feb '10
21 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via b90d74bcaadef20e47ac469d51fee1d1367ca57f (commit)
from 4316ce3c37be6fd8fbad4e9a0645bedb9a487b8e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=b90d74bcaadef20e47ac469d…
http://github.com/ceki/logback/commit/b90d74bcaadef20e47ac469d51fee1d1367ca…
commit b90d74bcaadef20e47ac469d51fee1d1367ca57f
Author: Ceki Gulcu <ceki(a)gimmel.(none)>
Date: Sun Feb 21 23:16:39 2010 +0100
- FileAppenderResilience test passes altough the code is still a mess.
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
index b0b7980..0ae0343 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
@@ -23,14 +23,15 @@ import java.nio.channels.FileChannel;
public class ResilientFileOutputStream extends OutputStream {
RecoveryCoordinator recoveryCoordinator;
- // private FileChannel fileChannel = null;
boolean bufferedIO;
int bufferSize;
FileOutputStream fos;
File file;
+ boolean presumedClean = true;
- public ResilientFileOutputStream(File file, boolean append) throws FileNotFoundException {
+ public ResilientFileOutputStream(File file, boolean append)
+ throws FileNotFoundException {
this.file = file;
fos = new FileOutputStream(file, append);
}
@@ -44,7 +45,7 @@ public class ResilientFileOutputStream extends OutputStream {
public void write(byte b[], int off, int len) throws IOException {
// existence of recoveryCoordinator indicates failed state
- if (recoveryCoordinator != null) {
+ if (recoveryCoordinator != null && !presumedClean) {
if (!recoveryCoordinator.isTooSoon()) {
performRecoveryAttempt();
}
@@ -56,6 +57,7 @@ public class ResilientFileOutputStream extends OutputStream {
fos.write(b, off, len);
postSuccessfulWrite();
} catch (IOException e) {
+ presumedClean = false;
recoveryCoordinator = new RecoveryCoordinator();
}
}
@@ -66,11 +68,11 @@ public class ResilientFileOutputStream extends OutputStream {
@Override
public void close() throws IOException {
- if(fos != null) {
+ if (fos != null) {
fos.close();
}
}
-
+
@Override
public void write(int b) throws IOException {
// existence of recoveryCoordinator indicates failed state
@@ -90,7 +92,14 @@ public class ResilientFileOutputStream extends OutputStream {
}
void performRecoveryAttempt() throws FileNotFoundException {
- fos = new FileOutputStream(file);
+ try {
+ close();
+ } catch (IOException e) {
+ }
+
+ // subsequent writes must always be in append mode
+ fos = new FileOutputStream(file, true);
+ presumedClean = true;
}
}
-----------------------------------------------------------------------
Summary of changes:
.../core/recovery/ResilientFileOutputStream.java | 21 ++++++++++++++-----
1 files changed, 15 insertions(+), 6 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-35-g4316ce3
by git-noreply@pixie.qos.ch 21 Feb '10
by git-noreply@pixie.qos.ch 21 Feb '10
21 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 4316ce3c37be6fd8fbad4e9a0645bedb9a487b8e (commit)
from ade00738d1df9cf6d56d3fb98ca28c5977e688d6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=4316ce3c37be6fd8fbad4e9a…
http://github.com/ceki/logback/commit/4316ce3c37be6fd8fbad4e9a0645bedb9a487…
commit 4316ce3c37be6fd8fbad4e9a0645bedb9a487b8e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sun Feb 21 22:44:54 2010 +0100
- Initial attempt at fixing LBCORE-109
diff --git a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
index 4e4c6aa..72be15c 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/FileAppender.java
@@ -14,11 +14,11 @@
package ch.qos.logback.core;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
+import ch.qos.logback.core.recovery.ResilientFileOutputStream;
import ch.qos.logback.core.util.FileUtil;
/**
@@ -55,8 +55,7 @@ public class FileAppender<E> extends WriterAppender<E> {
private boolean prudent = false;
- private FileChannel fileChannel = null;
-
+
/**
* As in most cases, the default constructor does nothing.
*/
@@ -190,16 +189,17 @@ public class FileAppender<E> extends WriterAppender<E> {
}
}
- FileOutputStream fileOutputStream = new FileOutputStream(file_name,
- append);
- if (prudent) {
- fileChannel = fileOutputStream.getChannel();
- }
+ ResilientFileOutputStream resilientFos = new ResilientFileOutputStream(file, append);
+
+
+ //FileOutputStream fileOutputStream = new FileOutputStream(file_name,
+ // append);
+
// Writer w = createWriter(fileOutputStream);
// if (bufferedIO) {
// w = new BufferedWriter(w, bufferSize);
// }
- setWriter(fileOutputStream);
+ setWriter(resilientFos);
}
}
@@ -243,6 +243,11 @@ public class FileAppender<E> extends WriterAppender<E> {
}
final private void safeWrite(E event) throws IOException {
+ ResilientFileOutputStream resilientFOS = (ResilientFileOutputStream) getOutputStream();
+ FileChannel fileChannel = resilientFOS.getChannel();
+ if(fileChannel == null) {
+ return;
+ }
FileLock fileLock = null;
try {
fileLock = fileChannel.lock();
@@ -261,7 +266,7 @@ public class FileAppender<E> extends WriterAppender<E> {
@Override
protected void writeOut(E event) throws IOException {
- if (prudent && fileChannel != null) {
+ if (prudent) {
safeWrite(event);
} else {
super.writeOut(event);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
index df991d7..e0410ed 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
@@ -86,6 +86,10 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
immediateFlush = value;
}
+ protected OutputStream getOutputStream() {
+ return outputStream;
+ }
+
/**
* Returns value of the <b>ImmediateFlush</b> option.
*/
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
new file mode 100644
index 0000000..eefdbf8
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
@@ -0,0 +1,30 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.recovery;
+
+public class RecoveryCoordinator {
+
+
+ long next = System.currentTimeMillis()+100;
+
+ public boolean isTooSoon() {
+ long now =System.currentTimeMillis();
+ if(now > next) {
+ next = now + 100;
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
new file mode 100644
index 0000000..b0b7980
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
@@ -0,0 +1,96 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.recovery;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.channels.FileChannel;
+
+public class ResilientFileOutputStream extends OutputStream {
+
+ RecoveryCoordinator recoveryCoordinator;
+ // private FileChannel fileChannel = null;
+ boolean bufferedIO;
+ int bufferSize;
+
+ FileOutputStream fos;
+ File file;
+
+ public ResilientFileOutputStream(File file, boolean append) throws FileNotFoundException {
+ this.file = file;
+ fos = new FileOutputStream(file, append);
+ }
+
+ public FileChannel getChannel() {
+ if (fos == null) {
+ return null;
+ }
+ return fos.getChannel();
+ }
+
+ public void write(byte b[], int off, int len) throws IOException {
+ // existence of recoveryCoordinator indicates failed state
+ if (recoveryCoordinator != null) {
+ if (!recoveryCoordinator.isTooSoon()) {
+ performRecoveryAttempt();
+ }
+ // we return regardless of the success of the recovery attempt
+ return;
+ }
+
+ try {
+ fos.write(b, off, len);
+ postSuccessfulWrite();
+ } catch (IOException e) {
+ recoveryCoordinator = new RecoveryCoordinator();
+ }
+ }
+
+ private void postSuccessfulWrite() {
+ recoveryCoordinator = null;
+ }
+
+ @Override
+ public void close() throws IOException {
+ if(fos != null) {
+ fos.close();
+ }
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ // existence of recoveryCoordinator indicates failed state
+ if (recoveryCoordinator != null) {
+ if (!recoveryCoordinator.isTooSoon()) {
+ performRecoveryAttempt();
+ }
+ // we return regardless of the success of the recovery attempt
+ return;
+ }
+ try {
+ fos.write(b);
+ postSuccessfulWrite();
+ } catch (IOException e) {
+ recoveryCoordinator = new RecoveryCoordinator();
+ }
+ }
+
+ void performRecoveryAttempt() throws FileNotFoundException {
+ fos = new FileOutputStream(file);
+ }
+
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
index 2f43dae..42ac3c7 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
@@ -1,10 +1,9 @@
package ch.qos.logback.core.encoder;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
-----------------------------------------------------------------------
Summary of changes:
.../java/ch/qos/logback/core/FileAppender.java | 25 +++--
.../java/ch/qos/logback/core/WriterAppender.java | 4 +
.../logback/core/recovery/RecoveryCoordinator.java | 30 ++++++
.../core/recovery/ResilientFileOutputStream.java | 96 ++++++++++++++++++++
.../core/encoder/ObjectEncodeDecodeTest.java | 3 +-
5 files changed, 146 insertions(+), 12 deletions(-)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/recovery/RecoveryCoordinator.java
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/recovery/ResilientFileOutputStream.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-34-gade0073
by git-noreply@pixie.qos.ch 20 Feb '10
by git-noreply@pixie.qos.ch 20 Feb '10
20 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via ade00738d1df9cf6d56d3fb98ca28c5977e688d6 (commit)
from 6a3e7041abd4d363afa4b8dd53a132f1f624a65c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=ade00738d1df9cf6d56d3fb9…
http://github.com/ceki/logback/commit/ade00738d1df9cf6d56d3fb98ca28c5977e68…
commit ade00738d1df9cf6d56d3fb98ca28c5977e688d6
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sun Feb 21 00:28:24 2010 +0100
- Added an example of a sample object encoder called
ObjectStreamEncoder and a corresponding InputStream called
EventObjectInputStream.
diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index 74cfd1b..637a1b4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -112,4 +112,7 @@ public class CoreConstants {
* context.
*/
public static final String HOSTNAME_KEY = "HOSTNAME";
+
+
+ public static int BYTES_PER_INT = 4;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
index 9dd0eaf..df991d7 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.spi.DeferredProcessingAware;
import ch.qos.logback.core.status.ErrorStatus;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java
new file mode 100644
index 0000000..e0f1181
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java
@@ -0,0 +1,56 @@
+package ch.qos.logback.core.encoder;
+
+import java.io.ByteArrayOutputStream;
+
+public class ByteArrayUtil {
+
+ // big-endian
+ static void writeInt(byte[] byteArray, int offset, int i) {
+ for (int j = 0; j < 4; j++) {
+ int shift = 24 - j * 8;
+ byteArray[offset + j] = (byte) (i >>> shift);
+ }
+ }
+
+ static void writeInt(ByteArrayOutputStream baos, int i) {
+ for (int j = 0; j < 4; j++) {
+ int shift = 24 - j * 8;
+ baos.write((byte) (i >>> shift));
+ }
+ }
+
+ // big-endian
+ static int readInt(byte[] byteArray, int offset) {
+ int i = 0;
+ for (int j = 0; j < 4; j++) {
+ int shift = 24 - j * 8;
+ i += (byteArray[offset + j] & 0xFF) << shift;
+ }
+ return i;
+ }
+
+ static public String toHexString(byte[] ba) {
+ StringBuffer sbuf = new StringBuffer();
+ for(byte b: ba) {
+ String s = Integer.toHexString( (int)(b & 0xff));
+ if(s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ }
+ return sbuf.toString();
+ }
+
+ static public byte[] hexStringToByteArray(String s) {
+ int len = s.length();
+ byte[] ba = new byte[len/2];
+
+ for(int i = 0; i < ba.length; i++) {
+ int j = i*2;
+ int t = Integer.parseInt(s.substring(j, j+2), 16);
+ byte b = (byte) (t & 0xFF);
+ ba[i] = b;
+ }
+ return ba;
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java
similarity index 95%
copy from logback-core/src/main/java/ch/qos/logback/core/Encoder.java
copy to logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java
index 1734e4a..18219be 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/Encoder.java
@@ -11,7 +11,7 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.core;
+package ch.qos.logback.core.encoder;
import java.io.IOException;
import java.io.OutputStream;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
index ac5febf..aaab297 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
@@ -3,7 +3,6 @@ package ch.qos.logback.core.encoder;
import java.io.IOException;
import java.io.OutputStream;
-import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.spi.ContextAwareBase;
abstract public class EncoderBase<E> extends ContextAwareBase implements Encoder<E> {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java
new file mode 100644
index 0000000..0d9726f
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java
@@ -0,0 +1,160 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under
+ * either the terms of the Eclipse Public License v1.0 as published by
+ * the Eclipse Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.encoder;
+
+import static ch.qos.logback.core.CoreConstants.BYTES_PER_INT;
+import static ch.qos.logback.core.encoder.ObjectStreamEncoder.START_PEBBLE;
+import static ch.qos.logback.core.encoder.ObjectStreamEncoder.STOP_PEBBLE;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Restitute the contents of an input stream as java objects.
+ *
+ * @author Ceki Gülcü
+ *
+ * @param <E>
+ */
+public class EventObjectInputStream<E> extends InputStream {
+
+ NonClosableInputStream ncis;
+ List<E> buffer = new ArrayList<E>();
+
+ int index = 0;
+
+ EventObjectInputStream(InputStream is) throws IOException {
+ this.ncis = new NonClosableInputStream(is);
+ }
+
+ @Override
+ public int read() throws IOException {
+ throw new UnsupportedOperationException(
+ "Only the readEvent method is supported.");
+ }
+
+ /**
+ * Returns the number of bytes available
+ */
+ public int available() throws IOException {
+ return ncis.available();
+ }
+
+ public E readEvent() throws IOException {
+
+ E event = getFromBuffer();
+ if (event != null) {
+ return event;
+ }
+
+ internalReset();
+ int count = readHeader();
+ if(count == -1) {
+ return null;
+ }
+ readPayload(count);
+ readFooter(count);
+ return getFromBuffer();
+ }
+
+ private void internalReset() {
+ index = 0;
+ buffer.clear();
+ }
+
+ E getFromBuffer() {
+ if (index >= buffer.size()) {
+ return null;
+ }
+ return buffer.get(this.index++);
+ }
+
+ int readHeader() throws IOException {
+ byte[] headerBA = new byte[4 * BYTES_PER_INT];
+ System.out.println("available="+ncis.available());
+ int bytesRead = ncis.read(headerBA);
+ if(bytesRead == -1) {
+ return -1;
+ }
+ System.out.println("**bytesRead="+bytesRead);
+
+ System.out.println(ByteArrayUtil.toHexString(headerBA));
+
+ int offset = 0;
+ int startPebble = ByteArrayUtil.readInt(headerBA, offset);
+ if (startPebble != START_PEBBLE) {
+ throw new IllegalStateException(
+ "Does not look like data created by ObjectStreamEncoder");
+ }
+ offset += BYTES_PER_INT;
+ int count = ByteArrayUtil.readInt(headerBA, offset);
+ offset += BYTES_PER_INT;
+ int endPointer = ByteArrayUtil.readInt(headerBA, offset);
+ offset += BYTES_PER_INT;
+ int checksum = ByteArrayUtil.readInt(headerBA, offset);
+ if (checksum != (START_PEBBLE ^ count)) {
+ throw new IllegalStateException("Invalid checksum");
+ }
+ return count;
+ }
+
+ @SuppressWarnings("unchecked")
+ E readEvents(ObjectInputStream ois) throws IOException {
+ E e = null;
+ try {
+ e = (E) ois.readObject();
+ buffer.add(e);
+ System.out.println("Read in event: "+e);
+ } catch (ClassNotFoundException e1) {
+ // FIXME Auto-generated catch block
+ e1.printStackTrace();
+ }
+ return e;
+ }
+
+ void readFooter(int count) throws IOException {
+ byte[] headerBA = new byte[2 * BYTES_PER_INT];
+ ncis.read(headerBA);
+
+ int offset = 0;
+ int stopPebble = ByteArrayUtil.readInt(headerBA, offset);
+ if (stopPebble != STOP_PEBBLE) {
+ throw new IllegalStateException(
+ "Looks like a corrupt stream");
+ }
+ offset += BYTES_PER_INT;
+ int checksum = ByteArrayUtil.readInt(headerBA, offset);
+ if (checksum != (STOP_PEBBLE ^ count)) {
+ throw new IllegalStateException("Invalid checksum");
+ }
+ }
+
+ void readPayload(int count) throws IOException {
+ List<E> eventList = new ArrayList<E>(count);
+ ObjectInputStream ois = new ObjectInputStream(ncis);
+ for (int i = 0; i < count; i++) {
+ E e = (E) readEvents(ois);
+ eventList.add(e);
+ }
+ ois.close();
+ }
+
+ public void close() throws IOException {
+ ncis.realClose();
+ }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java
new file mode 100644
index 0000000..716339b
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java
@@ -0,0 +1,25 @@
+package ch.qos.logback.core.encoder;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class NonClosableInputStream extends FilterInputStream {
+
+ NonClosableInputStream(InputStream is) {
+ super(is);
+ }
+
+ /**
+ * The whole point of this input stream is to ignore invocations to close()
+ */
+ @Override
+ public void close() {
+
+ }
+
+ public void realClose() throws IOException {
+ super.close();
+ }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java
new file mode 100644
index 0000000..036e498
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java
@@ -0,0 +1,95 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.encoder;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import ch.qos.logback.core.CoreConstants;
+
+/**
+ * Write out events as java objects.
+ *
+ * @author Ceki Gülcü
+ *
+ * @param <E>
+ */
+public class ObjectStreamEncoder<E> extends EncoderBase<E> {
+
+ static public int START_PEBBLE = 1853421169;
+ //static public int START_PEBBLE = 1;
+
+ static public int STOP_PEBBLE = 640373619;
+
+ private int MAX_BUFFER_SIZE = 100;
+
+ List<E> bufferList = new ArrayList<E>(MAX_BUFFER_SIZE);
+
+ public void doEncode(E event) throws IOException {
+ bufferList.add(event);
+ if (bufferList.size() == MAX_BUFFER_SIZE) {
+ writeBuffer();
+ }
+ }
+
+ void writeHeader(ByteArrayOutputStream baos, int bufferSize) {
+ ByteArrayUtil.writeInt(baos, START_PEBBLE);
+ ByteArrayUtil.writeInt(baos, bufferSize);
+ ByteArrayUtil.writeInt(baos, 0);
+ ByteArrayUtil.writeInt(baos, START_PEBBLE^bufferSize);
+ }
+
+ void writeFooter(ByteArrayOutputStream baos, int bufferSize) {
+ ByteArrayUtil.writeInt(baos, STOP_PEBBLE);
+ ByteArrayUtil.writeInt(baos, STOP_PEBBLE ^ bufferSize);
+ }
+ void writeBuffer() throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
+
+ int size = bufferList.size();
+ writeHeader(baos, size);
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ for (E e : bufferList) {
+ oos.writeObject(e);
+ }
+ bufferList.clear();
+ oos.flush();
+
+ writeFooter(baos, size);
+
+ byte[] byteArray = baos.toByteArray();
+ oos.close();
+ writeEndPosition(byteArray);
+ outputStream.write(byteArray);
+
+ }
+
+ void writeEndPosition(byte[] byteArray) {
+ int offset = 2*CoreConstants.BYTES_PER_INT;
+ ByteArrayUtil.writeInt(byteArray,offset, byteArray.length-offset);
+ }
+
+ public void init(OutputStream os) throws IOException {
+ super.init(os);
+ bufferList.clear();
+ }
+
+ public void close() throws IOException {
+ writeBuffer();
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java b/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java
index a3af565..d4eca59 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/AllCoreTest.java
@@ -27,7 +27,8 @@ import org.junit.runners.Suite.SuiteClasses;
ch.qos.logback.core.appender.PackageTest.class,
ch.qos.logback.core.spi.PackageTest.class,
ch.qos.logback.core.rolling.PackageTest.class,
- ch.qos.logback.core.sift.PackageTest.class})
+ ch.qos.logback.core.sift.PackageTest.class,
+ ch.qos.logback.core.encoder.PackageTest.class})
public class AllCoreTest {
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
index 6443b0a..0566170 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
@@ -21,8 +21,8 @@ import java.io.IOException;
import org.junit.Test;
import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.encoder.DummyEncoder;
+import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.layout.DummyLayout;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java
new file mode 100644
index 0000000..9dd50aa
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java
@@ -0,0 +1,53 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
+ *
+ * This program and the accompanying materials are dual-licensed under either
+ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
+ * Foundation
+ *
+ * or (per the licensee's choosing)
+ *
+ * under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ */
+package ch.qos.logback.core.encoder;
+
+import static org.junit.Assert.*;
+
+import java.util.Random;
+
+import org.junit.Test;
+
+public class ByteArrayUtilTest {
+
+ int BA_SIZE = 16;
+ byte[] byteArray = new byte[BA_SIZE];
+
+ Random random = new Random(18532235);
+
+ @Test
+ public void smoke() {
+ verifyLoop(byteArray, 0, 0);
+ verifyLoop(byteArray, 0, 10);
+ verifyLoop(byteArray, 0, Integer.MAX_VALUE);
+ verifyLoop(byteArray, 0, Integer.MIN_VALUE);
+ }
+
+ @Test
+ public void random() {
+ for(int i = 0; i < 100000; i++) {
+ int rOffset = random.nextInt(BA_SIZE-4);
+ int rInt = random.nextInt();
+ verifyLoop(byteArray, rOffset, rInt);
+ }
+ }
+
+ void verifyLoop(byte[] ba, int offset, int expected) {
+ ByteArrayUtil.writeInt(byteArray, offset, expected);
+ int back = ByteArrayUtil.readInt(byteArray, offset);
+ assertEquals(expected, back);
+
+ }
+
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
new file mode 100644
index 0000000..2f43dae
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
@@ -0,0 +1,82 @@
+package ch.qos.logback.core.encoder;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.CoreTestConstants;
+
+public class ObjectEncodeDecodeTest {
+
+ ObjectStreamEncoder<String> encoder = new ObjectStreamEncoder<String>();
+ EventObjectInputStream<String> eventStream;
+
+ int diff = RandomUtil.getPositiveInt();
+ protected String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff
+ + "/";
+
+ @Before
+ public void setUp() {
+ File randomOupurDirFile = new File(randomOutputDir);
+ randomOupurDirFile.mkdirs();
+ }
+
+ void encodeList(File file, List<String> list) throws IOException {
+ FileOutputStream fos = new FileOutputStream(file);
+ encoder.init(fos);
+ for (String s: list) {
+ encoder.doEncode(s);
+ }
+ encoder.close();
+ fos.close();
+ }
+
+
+ List<String> decodeList(File file) throws IOException {
+ FileInputStream fis = new FileInputStream(file);
+ eventStream = new EventObjectInputStream<String>(fis);
+ List<String> back = new ArrayList<String>();
+ String e;
+ while((e=eventStream.readEvent()) != null) {
+ back.add(e);
+ }
+ return back;
+ }
+
+ @Test
+ public void singleBatch() throws IOException {
+ File file = new File(randomOutputDir + "x.lbo");
+
+ List<String> witness = new ArrayList<String>();
+ for (int i = 0; i < 10; i++) {
+ witness.add("hello" + i);
+ }
+ encodeList(file, witness);
+ List<String> back = decodeList(file);
+ assertEquals(witness, back);
+ }
+
+ @Test
+ public void multipleBatches() throws IOException {
+ File file = new File(randomOutputDir + "m.lbo");
+
+ List<String> witness = new ArrayList<String>();
+ for (int i = 0; i < 100*10; i++) {
+ witness.add("hello" + i);
+ }
+ encodeList(file, witness);
+ List<String> back = decodeList(file);
+ assertEquals(witness, back);
+ }
+
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java
similarity index 56%
rename from logback-core/src/main/java/ch/qos/logback/core/Encoder.java
rename to logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java
index 1734e4a..f49d572 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/PackageTest.java
@@ -11,18 +11,12 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
-package ch.qos.logback.core;
+package ch.qos.logback.core.encoder;
-import java.io.IOException;
-import java.io.OutputStream;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
-import ch.qos.logback.core.spi.ContextAware;
-import ch.qos.logback.core.spi.LifeCycle;
-
-public interface Encoder<E> extends ContextAware, LifeCycle {
-
- void doEncode(E event) throws IOException;
- void init(OutputStream os) throws IOException;
- void close() throws IOException;
-
+(a)RunWith(Suite.class)
+(a)Suite.SuiteClasses( { ByteArrayUtilTest.class, ObjectEncodeDecodeTest.class })
+public class PackageTest {
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
index 3a1d898..ba31085 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/MultiThreadedRollingTest.java
@@ -30,10 +30,10 @@ import org.junit.Test;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.contention.MultiThreadedHarness;
import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
import ch.qos.logback.core.encoder.EchoEncoder;
+import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.status.StatusChecker;
import ch.qos.logback.core.testUtil.Env;
import ch.qos.logback.core.testUtil.RandomUtil;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
index b08df19..b1e43e1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
@@ -24,8 +24,8 @@ import org.junit.Test;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.encoder.EchoEncoder;
+import ch.qos.logback.core.encoder.Encoder;
import ch.qos.logback.core.util.Compare;
import ch.qos.logback.core.util.CoreTestConstants;
-----------------------------------------------------------------------
Summary of changes:
.../java/ch/qos/logback/core/CoreConstants.java | 3 +
.../java/ch/qos/logback/core/WriterAppender.java | 1 +
.../ch/qos/logback/core/encoder/ByteArrayUtil.java | 56 +++++++
.../ch/qos/logback/core/{ => encoder}/Encoder.java | 2 +-
.../ch/qos/logback/core/encoder/EncoderBase.java | 1 -
.../core/encoder/EventObjectInputStream.java | 160 ++++++++++++++++++++
.../core/encoder/NonClosableInputStream.java | 25 +++
.../logback/core/encoder/ObjectStreamEncoder.java | 95 ++++++++++++
.../test/java/ch/qos/logback/core/AllCoreTest.java | 3 +-
.../logback/core/appender/DummyAppenderTest.java | 2 +-
.../logback/core/encoder/ByteArrayUtilTest.java | 53 +++++++
.../core/encoder/ObjectEncodeDecodeTest.java | 82 ++++++++++
.../ch/qos/logback/core/encoder}/PackageTest.java | 7 +-
.../core/rolling/MultiThreadedRollingTest.java | 2 +-
.../ch/qos/logback/core/rolling/RenamingTest.java | 2 +-
15 files changed, 484 insertions(+), 10 deletions(-)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/encoder/ByteArrayUtil.java
rename logback-core/src/main/java/ch/qos/logback/core/{ => encoder}/Encoder.java (95%)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/encoder/EventObjectInputStream.java
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/encoder/NonClosableInputStream.java
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/encoder/ObjectStreamEncoder.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/encoder/ByteArrayUtilTest.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/encoder/ObjectEncodeDecodeTest.java
copy {logback-classic/src/test/java/ch/qos/logback/classic/html => logback-core/src/test/java/ch/qos/logback/core/encoder}/PackageTest.java (83%)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-33-g6a3e704
by git-noreply@pixie.qos.ch 19 Feb '10
by git-noreply@pixie.qos.ch 19 Feb '10
19 Feb '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, encoder has been updated
via 6a3e7041abd4d363afa4b8dd53a132f1f624a65c (commit)
from d2e55bbf1ee4c99949cc82117a3481b8d13dcee7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=6a3e7041abd4d363afa4b8dd…
http://github.com/ceki/logback/commit/6a3e7041abd4d363afa4b8dd53a132f1f624a…
commit 6a3e7041abd4d363afa4b8dd53a132f1f624a65c
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Feb 19 14:12:08 2010 +0100
- The Encoder interface is handed an ObjectStream when the
init(ObjectStream) method is called. The Encoder needs to reference
the OS passed to it in future operations. The enclosing Appender is
responsible of signaling the Encoder when the current OS is closed (by
invoking encopder.close()) and when a new one is opened (by invoking
encoder.inig(os));
- All tests pass.
diff --git a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java b/logback-core/src/main/java/ch/qos/logback/core/Encoder.java
index 28cb9fc..1734e4a 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/Encoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/Encoder.java
@@ -21,9 +21,8 @@ import ch.qos.logback.core.spi.LifeCycle;
public interface Encoder<E> extends ContextAware, LifeCycle {
- void doEncode(E event, OutputStream os) throws IOException;
-
+ void doEncode(E event) throws IOException;
void init(OutputStream os) throws IOException;
- void close(OutputStream os) throws IOException;
+ void close() throws IOException;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
index 63d4867..9dd0eaf 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
@@ -203,7 +203,7 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
void encoderClose() {
if (encoder != null && this.outputStream != null) {
try {
- encoder.close(outputStream);
+ encoder.close();
} catch (IOException ioe) {
this.started = false;
addStatus(new ErrorStatus("Failed to write footer for appender named ["
@@ -232,16 +232,12 @@ public class WriterAppender<E> extends UnsynchronizedAppenderBase<E> {
return;
}
- try {
- encoder.init(outputStream);
- } catch (IOException e) {
- addError("Failied to initialize encoder", e);
- }
+ encoderInit();
}
}
protected void writeOut(E event) throws IOException {
- this.encoder.doEncode(event, outputStream);
+ this.encoder.doEncode(event);
}
/**
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/EchoEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
similarity index 79%
rename from logback-core/src/test/java/ch/qos/logback/core/encoder/EchoEncoder.java
rename to logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
index 5cc19f5..e239629 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/encoder/EchoEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
@@ -26,22 +26,23 @@ public class EchoEncoder<E> extends EncoderBase<E> {
public EchoEncoder() {
}
- public void doEncode(E event, OutputStream os) throws IOException {
+ public void doEncode(E event) throws IOException {
String val = event + CoreConstants.LINE_SEPARATOR;
- os.write(val.getBytes());
+ outputStream.write(val.getBytes());
}
- public void close(OutputStream os) throws IOException {
+ public void close() throws IOException {
if (fileFooter == null) {
return;
}
- os.write(fileFooter.getBytes());
+ outputStream.write(fileFooter.getBytes());
}
public void init(OutputStream os) throws IOException {
+ super.init(os);
if (fileHeader == null) {
return;
}
- os.write(fileHeader.getBytes());
+ outputStream.write(fileHeader.getBytes());
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
index 6d53222..ac5febf 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EncoderBase.java
@@ -1,13 +1,21 @@
package ch.qos.logback.core.encoder;
+import java.io.IOException;
+import java.io.OutputStream;
+
import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.spi.ContextAwareBase;
abstract public class EncoderBase<E> extends ContextAwareBase implements Encoder<E> {
protected boolean started;
-
+ protected OutputStream outputStream;
+
+ public void init(OutputStream os) throws IOException {
+ this.outputStream = os;
+ }
+
public boolean isStarted() {
return started;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
index 11d938b..cbbc966 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/html/LayoutWrappingEncoder.java
@@ -4,14 +4,11 @@ import java.io.IOException;
import java.io.OutputStream;
import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.Layout;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.encoder.EncoderBase;
-public class LayoutWrappingEncoder<E> extends ContextAwareBase implements
- Encoder<E> {
+public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
- boolean started;
protected Layout<E> layout;
public Layout<E> getLayout() {
@@ -24,11 +21,12 @@ public class LayoutWrappingEncoder<E> extends ContextAwareBase implements
public void init(OutputStream os) throws IOException {
- writeHeader(os);
+ super.init(os);
+ writeHeader();
}
- public void close(OutputStream os) throws IOException {
- writeFooter(os);
+ public void close() throws IOException {
+ writeFooter();
}
private void appendIfNotNull(StringBuilder sb, String s) {
@@ -37,8 +35,8 @@ public class LayoutWrappingEncoder<E> extends ContextAwareBase implements
}
}
- void writeHeader(OutputStream os) throws IOException {
- if (layout != null && (os != null)) {
+ void writeHeader() throws IOException {
+ if (layout != null && (outputStream != null)) {
StringBuilder sb = new StringBuilder();
appendIfNotNull(sb, layout.getFileHeader());
appendIfNotNull(sb, layout.getPresentationHeader());
@@ -47,29 +45,29 @@ public class LayoutWrappingEncoder<E> extends ContextAwareBase implements
// If at least one of file header or presentation header were not
// null, then append a line separator.
// This should be useful in most cases and should not hurt.
- os.write(sb.toString().getBytes());
- os.flush();
+ outputStream.write(sb.toString().getBytes());
+ outputStream.flush();
}
}
}
- void writeFooter(OutputStream os) throws IOException {
- if (layout != null && os != null) {
+ void writeFooter() throws IOException {
+ if (layout != null && outputStream != null) {
StringBuilder sb = new StringBuilder();
appendIfNotNull(sb, layout.getPresentationFooter());
appendIfNotNull(sb, layout.getFileFooter());
if (sb.length() > 0) {
- os.write(sb.toString().getBytes());
- os.flush();
+ outputStream.write(sb.toString().getBytes());
+ outputStream.flush();
}
}
}
- public void doEncode(E event, OutputStream os) throws IOException {
+ public void doEncode(E event) throws IOException {
String txt = layout.doLayout(event);
- os.write(txt.getBytes());
- os.flush();
+ outputStream.write(txt.getBytes());
+ outputStream.flush();
}
public boolean isStarted() {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
index 44f2f51..6443b0a 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/appender/DummyAppenderTest.java
@@ -16,10 +16,12 @@ package ch.qos.logback.core.appender;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import org.junit.Test;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.Encoder;
import ch.qos.logback.core.encoder.DummyEncoder;
import ch.qos.logback.core.layout.DummyLayout;
@@ -40,8 +42,10 @@ public class DummyAppenderTest extends AbstractAppenderTest<Object> {
}
@Test
- public void testBasic() {
- da.setEncoder(new DummyEncoder<Object>());
+ public void testBasic() throws IOException {
+ Encoder<Object> encoder = new DummyEncoder<Object>();
+ encoder.init(baos);
+ da.setEncoder(encoder);
da.start();
da.doAppend(new Object());
assertEquals(DummyLayout.DUMMY, baos.toString());
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java
index 998ed52..f214557 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/DummyEncoder.java
@@ -41,8 +41,8 @@ public class DummyEncoder<E> extends EncoderBase<E> {
this.val = val;
}
- public void doEncode(E event, OutputStream os) throws IOException {
- writeOut(os, val);
+ public void doEncode(E event) throws IOException {
+ writeOut(val);
}
private void appendIfNotNull(StringBuilder sb, String s) {
@@ -51,15 +51,15 @@ public class DummyEncoder<E> extends EncoderBase<E> {
}
}
- void writeOut(OutputStream os, String s) throws IOException {
+ void writeOut(String s) throws IOException {
if (encodingName == null) {
- os.write(s.getBytes());
+ outputStream.write(s.getBytes());
} else {
- os.write(s.getBytes(encodingName));
+ outputStream.write(s.getBytes(encodingName));
}
}
- void writeHeader(OutputStream os) throws IOException {
+ void writeHeader() throws IOException {
StringBuilder sb = new StringBuilder();
appendIfNotNull(sb, fileHeader);
if (sb.length() > 0) {
@@ -67,22 +67,23 @@ public class DummyEncoder<E> extends EncoderBase<E> {
// If at least one of file header or presentation header were not
// null, then append a line separator.
// This should be useful in most cases and should not hurt.
- writeOut(os, sb.toString());
+ writeOut(sb.toString());
}
}
public void init(OutputStream os) throws IOException {
- writeHeader(os);
+ super.init(os);
+ writeHeader();
}
- public void close(OutputStream os) throws IOException {
+ public void close() throws IOException {
if (fileFooter == null) {
return;
}
if (encodingName == null) {
- os.write(fileFooter.getBytes());
+ outputStream.write(fileFooter.getBytes());
} else {
- os.write(fileFooter.getBytes(encodingName));
+ outputStream.write(fileFooter.getBytes(encodingName));
}
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java b/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java
index 62afe4f..e3c4d4d 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/encoder/NopEncoder.java
@@ -18,10 +18,10 @@ import java.io.OutputStream;
public class NopEncoder<E> extends EncoderBase<E> {
- public void close(OutputStream os) throws IOException {
+ public void close() throws IOException {
}
- public void doEncode(E event, OutputStream os) throws IOException {
+ public void doEncode(E event) throws IOException {
}
public void init(OutputStream os) throws IOException {
diff --git a/logback-examples/src/main/java/chapter11/TrivialLogbackAppender.java b/logback-examples/src/main/java/chapter11/TrivialLogbackAppender.java
index e2b3d74..bbcad79 100644
--- a/logback-examples/src/main/java/chapter11/TrivialLogbackAppender.java
+++ b/logback-examples/src/main/java/chapter11/TrivialLogbackAppender.java
@@ -37,6 +37,10 @@ public class TrivialLogbackAppender extends AppenderBase<ILoggingEvent> {
addError("No encoder set for the appender named [" + name + "].");
return;
}
+ try {
+ encoder.init(System.out);
+ } catch (IOException e) {
+ }
super.start();
}
@@ -45,7 +49,7 @@ public class TrivialLogbackAppender extends AppenderBase<ILoggingEvent> {
// note that AppenderBase.doAppend will invoke this method only if
// this appender was successfully started.
try {
- this.encoder.doEncode(loggingevent, System.out);
+ this.encoder.doEncode(loggingevent);
} catch (IOException e) {
// we can't do much with the exception except halting
super.stop();
diff --git a/logback-examples/src/main/java/chapter4/CountingConsoleAppender.java b/logback-examples/src/main/java/chapter4/CountingConsoleAppender.java
index b4f0bec..5e18f14 100644
--- a/logback-examples/src/main/java/chapter4/CountingConsoleAppender.java
+++ b/logback-examples/src/main/java/chapter4/CountingConsoleAppender.java
@@ -45,6 +45,10 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> {
return;
}
+ try {
+ encoder.init(System.out);
+ } catch (IOException e) {
+ }
super.start();
}
@@ -54,7 +58,7 @@ public class CountingConsoleAppender extends AppenderBase<ILoggingEvent> {
}
// output the events as formatted by our layout
try {
- this.encoder.doEncode(event, System.out);
+ this.encoder.doEncode(event);
} catch (IOException e) {
}
-----------------------------------------------------------------------
Summary of changes:
.../src/main/java/ch/qos/logback/core/Encoder.java | 5 +--
.../java/ch/qos/logback/core/WriterAppender.java | 10 ++----
.../ch/qos/logback/core/encoder/EchoEncoder.java | 11 +++---
.../ch/qos/logback/core/encoder/EncoderBase.java | 10 +++++-
.../logback/core/html/LayoutWrappingEncoder.java | 36 +++++++++----------
.../logback/core/appender/DummyAppenderTest.java | 8 +++-
.../ch/qos/logback/core/encoder/DummyEncoder.java | 23 ++++++------
.../ch/qos/logback/core/encoder/NopEncoder.java | 4 +-
.../java/chapter11/TrivialLogbackAppender.java | 6 +++-
.../java/chapter4/CountingConsoleAppender.java | 6 +++-
10 files changed, 67 insertions(+), 52 deletions(-)
rename logback-core/src/{test => main}/java/ch/qos/logback/core/encoder/EchoEncoder.java (79%)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0