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
May 2012
- 6 participants
- 127 discussions

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.2-8-g22126c5
by git-noreply@pixie.qos.ch 03 May '12
by git-noreply@pixie.qos.ch 03 May '12
03 May '12
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, master has been updated
via 22126c5c13088502dc0b5c9c7dda4218ac3c8978 (commit)
from 0a2446b85f3ba811d9cbd153f3e591ca44ea4e0f (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=22126c5c13088502dc0b5c9c…
http://github.com/ceki/logback/commit/22126c5c13088502dc0b5c9c7dda4218ac3c8…
commit 22126c5c13088502dc0b5c9c7dda4218ac3c8978
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu May 3 18:38:10 2012 +0200
outputPatternAsPresentationHeader renamed as outputPatternAsHeader and is now false by default
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
index 6890b9e..8c8de83 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
@@ -46,7 +46,6 @@ public class BasicConfigurator {
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(lc);
- pl.setOutputPatternAsPresentationHeader(false);
pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.start();
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java b/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java
index 5bf4705..9e9782e 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/encoder/PatternLayoutEncoder.java
@@ -24,7 +24,7 @@ public class PatternLayoutEncoder extends PatternLayoutEncoderBase<ILoggingEvent
PatternLayout patternLayout = new PatternLayout();
patternLayout.setContext(context);
patternLayout.setPattern(getPattern());
- patternLayout.setOutputPatternAsPresentationHeader(outputPatternAsPresentationHeader);
+ patternLayout.setOutputPatternAsHeader(outputPatternAsHeader);
patternLayout.start();
this.layout = patternLayout;
super.start();
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
index 3f8cb7d..2c90cec 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
@@ -60,7 +60,7 @@ public class LevelChangePropagator extends ContextAwareBase implements LoggerCon
private void propagate(Logger logger, Level level) {
addInfo("Propagating " + level + " level on " + logger + " onto the JUL framework");
java.util.logging.Logger julLogger = JULHelper.asJULLogger(logger);
- // prevent garbage collection of jul loggers levels were propagated to
+ // prevent garbage collection of jul loggers whose level we set
// see also http://jira.qos.ch/browse/LBCLASSIC-256
julLoggerSet.add(julLogger);
java.util.logging.Level julLevel = JULHelper.asJULLevel(level);
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
index bab8c26..6def85c 100644
--- 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
@@ -59,7 +59,7 @@ public class PatternLayoutEncoderTest {
void init(ByteArrayOutputStream baos) throws IOException {
ple.start();
- ((PatternLayout) ple.getLayout()).setOutputPatternAsPresentationHeader(false);
+ ((PatternLayout) ple.getLayout()).setOutputPatternAsHeader(false);
ple.init(baos);
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
index aacc7c6..223584c 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
@@ -1,12 +1,5 @@
package ch.qos.logback.classic.issue.lbcore243;
-/**
- * Created with IntelliJ IDEA.
- * User: ceki
- * Date: 26.04.12
- * Time: 21:52
- * To change this template use File | Settings | File Templates.
- */
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
index 3d4f49e..b69f357 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
@@ -12,7 +12,8 @@
<encoder>
<Pattern>%d{ISO8601} %5p [%t] %c - %m%n</Pattern>
<immediateFlush>false</immediateFlush>
- <!--<charset>UTF-8</charset>-->
+ <outputPatternAsHeader>true</outputPatternAsHeader>
+ <charset>UTF-8</charset>
</encoder>
</appender>
<root>
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
index 71a15b8..8ebd4de 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java
@@ -90,7 +90,7 @@ public class SMTPAppender_GreenTest {
PatternLayout layout = new PatternLayout();
layout.setContext(lc);
layout.setFileHeader(HEADER);
- layout.setOutputPatternAsPresentationHeader(false);
+ layout.setOutputPatternAsHeader(false);
layout.setPattern("%-4relative %mdc [%thread] %-5level %class - %msg%n");
layout.setFileFooter(FOOTER);
layout.start();
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
index fa5cfab..3fe2ad8 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
@@ -34,7 +34,7 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
Map<String, String> instanceConverterMap = new HashMap<String, String>();
- protected boolean outputPatternAsHeader = true;
+ protected boolean outputPatternAsHeader = false;
/**
* Concrete implementations of this class are responsible for elaborating the
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
index a094dcc..628afa1 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
@@ -55,7 +55,7 @@ public class PatternLayoutEncoderBase<E> extends LayoutWrappingEncoder<E> {
* @deprecated replaced by {@link #setOutputPatternAsHeader(boolean)}
*/
public void setOutputPatternAsPresentationHeader(boolean outputPatternAsHeader) {
- addWarn("outputPatternAsPresentationHeader option is deprecated. Use outputPatternAsHeader option instead.");
+ addWarn("[outputPatternAsPresentationHeader] property is deprecated. Please use [outputPatternAsHeader] option instead.");
this.outputPatternAsHeader = outputPatternAsHeader;
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java
index ce730de..d33e8c0 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayout.java
@@ -29,7 +29,6 @@ public class SamplePatternLayout<E> extends PatternLayoutBase<E> {
public SamplePatternLayout() {
converterMap.put("OTT", Converter123.class.getName());
converterMap.put("hello", ConverterHello.class.getName());
- outputPatternAsPresentationHeader = false;
}
public Map<String, String> getDefaultConverterMap() {
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index de31c49..3574056 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -377,7 +377,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
a file. The target file is specified by the <span
class="prop">File</span> option. If the file already exists, it
is either appended to, or truncated depending on the value of the
- <span class="prop">Append</span> option.
+ <span class="prop">append</span> property.
</p>
<table class="bodyTable properties striped">
@@ -390,10 +390,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<td><b><span class="prop">append</span></b></td>
<td><code>boolean</code></td>
<td>If true, events are appended at the end of an existing
- file. Otherwise, if <span class="prop">Append</span> is
- false, any existing file is truncated. The <span
- class="prop">Append</span> option is set to true by
- default.
+ file. Otherwise, if <span class="prop">append</span> is false,
+ any existing file is truncated. The <span
+ class="option">append</span> option is set to true by default.
</td>
</tr>
<tr >
@@ -472,6 +471,15 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</tr>
</table>
+ <p><span class="label notice">Immediate Flush</span> By default,
+ each log event is immediately flushed to the underlying output
+ stream. For significantly increased logging throughput, you may
+ want to set the <span class="prop">immediateFlush</span> property
+ to <code>false</code> of the underlying encoder. Encoders and in
+ particular <a
+ href="encoders.html#LayoutWrappingEncoder"><code>LayoutWrappingEncoder</code></a>
+ are described in a separate chapter.</p>
+
<p>Below is an example of a configuration file for
<code>FileAppender</code>:
</p>
diff --git a/logback-site/src/site/pages/manual/encoders.html b/logback-site/src/site/pages/manual/encoders.html
index 5e95765..6de5b7b 100644
--- a/logback-site/src/site/pages/manual/encoders.html
+++ b/logback-site/src/site/pages/manual/encoders.html
@@ -142,11 +142,13 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
protected Layout<E> layout;
private Charset charset;
+ private boolean immediateFlush = true;
public void doEncode(E event) throws IOException {
String txt = layout.doLayout(event);
outputStream.write(convertToBytes(txt));
- outputStream.flush();
+ if (immediateFlush)
+ outputStream.flush();
}
private byte[] convertToBytes(String s) {
@@ -162,10 +164,15 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
layout convert the incoming event into string. The resulting text
string is converted to bytes according to the charset encoding
chosen by the user. Those bytes are then written to the
- <code>OutputStream</code> given by the owning appender and the
- <code>OutputStream</code> is immediately flushed.
+ <code>OutputStream</code> given by the owning appender. By
+ default, the <code>OutputStream</code> is immediately flushed,
+ unless the <span class="prop">immediateFlush</span> property is
+ explicitly set to false. Setting the <span
+ class="prop">immediateFlush</span> property to false can
+ significantly improve logging throughput. See
+ <code>PatternLayoutEncoder</code> below for example.
</p>
-
+
<h2><a name="PatternLayoutEncoder"
href="#PatternLayoutEncoder">PatternLayoutEncoder</a></h2>
@@ -186,9 +193,61 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
logback error codes</a>.
</p>
+ <h4><a name="outputPatternAsHeader" href="#outputPatternAsHeader">Output pattern string as header</a></h4>
+
+ <p>In order to facilitate parsing of log files, logback can insert
+ the pattern used for the log output at the top of log files. This
+ feature is <b>disabled</b> by default. It can be enabled by
+ setting the <span class="prop">outputPatternAsHeader</span>
+ property to 'true' for relevant
+ <code>PatternLayoutEncoder</code>. Here is an example:</p>
+
+<pre class="prettyprint"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>foo.log</file>
+ <encoder>
+ <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
+ <b><outputPatternAsHeader>true</outputPatternAsHeader></b>
+ </encoder>
+</appender></pre>
+
+ <p>This will result output akin to the following in the log file:</p>
+
+ <pre>#logback.classic pattern: %d [%thread] %-5level %logger{36} - %msg%n
+2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hello world
+2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hi again
+...</pre>
+
+ <p>The line starting with "#logback.classic pattern" is newly
+ inserted pattern line.</p>
+
+ <h4><span class="prop">immediateFlush</span> property</h4>
+
+ <p>As a sub-class of <a
+ href="../xref/ch/qos/logback/core/encoder/LayoutWrappingEncoder.html"><code>LayoutWrappingEncoder</code></a>,
+ <code>PatternLayoutEncoder</code> admits the <span
+ class="prop">immediateFlush</span> property. The default value
+ for <span class="prop">immediateFlush</span> is 'false'. However,
+ by setting this property to 'false', logging throughput can be
+ quadrupled although your mileage may vary.
+ </p>
+
+ <p>Below is a sample configuration for a
+ <code>FileAppender</code> containing a
+ <code>PatternLayoutEncoder</code> with its <span
+ class="prop">immediateFlush</span> property set to 'false'.</p>
+<pre class="prettyprint"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>foo.log</file>
+ <encoder>
+ <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
+ <!-- this quadruples logging throughput -->
+ <b><immediateFlush>false</immediateFlush></b>
+ </encoder>
+</appender></pre>
+
+
- <script src="../templates/footer.js" type="text/javascript"></script>
+ <script src="../templates/footer.js" type="text/javascript"></script>
</div>
</body>
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 26126fe..70c8002 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -32,41 +32,30 @@
<h3>3rd of May, 2012 - Release of version 1.0.3</h3>
- <p><code>PatternLayoutEncoder</code> now admits the <span
- class="option">immediateFlush</span> option (set to true by
- default). By setting this option to false, logging throughput can
- be quadrupled, although your mileage may vary. This option was
- requested in <a
+ <p><code>PatternLayoutEncoder</code> class now admits the <span
+ class="prop"><a
+ href="manual/encoders.html#LayoutWrappingEncoder">immediateFlush</a></span>
+ property (set to true by default). By setting this property to
+ 'false', logging throughput can be quadrupled, although your
+ mileage may vary. This enhancement was requested in <a
href="http://jira.qos.ch/browse/LBCORE-243">LBCORE-243</a>.
</p>
- <p>In order to facilitate parsing of log files, logback can now
- insert the pattern used for the log output at the top of log
- files. This feature was requested by James Strachan in <a
+ <p>In order to facilitate parsing of log files, logback can now <a
+ href="manual/encoders.html#outputPatternAsHeader">output the
+ pattern</a> used for the log output at the top of log files as a
+ header. This feature was requested by James Strachan in <a
href="http://jira.qos.ch/browse/LBCORE-234">LBCORE-234</a>.
- However, this feature is <b>not</b> enabled by default. It can be
- enabled by setting the <span
- class="option">outputPatternAsHeader</span> option to 'true' for
- the relevant encoder. Here is an example:</p>
+ </p>
-<pre class="prettyprint"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>foo.log</file>
- <encoder>
- <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
- <b><outputPatternAsHeader>true</outputPatternAsHeader></b>
- </encoder>
-</appender></pre>
+ <p><code>LevelChangePropagator</code> now retains references to
+ j.u.l. loggers whose level it sets. This fixes garbage collection
+ issues reported in <a
+ href="http://jira.qos.ch/browse/LBCLASSIC-256">LBCLASSIC-256</a>
+ by Samuel Stanojevic who also provided the appropriate patch.
+ </p>
- <p>This will result output akin to the following in the log file:</p>
-
- <pre>#logback.classic pattern: %d [%thread] %-5level %logger{36} - %msg%n
-2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hello world
-2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hi again
-...</pre>
-
- <p>The line starting with "#logback.classic pattern" is newly
- inserted pattern line.</p>
<h3>26th of April, 2012 - Release of version 1.0.2</h3>
@@ -77,7 +66,7 @@
its pattern at the top of log files</h4>
<p>This feature, although still available, is no longer enabled by
- default. See release 1.0.3 for details.
+ default. See release notes for version 1.0.3 for details.
</p>
@@ -119,7 +108,7 @@
</p>
<p>Added new property the <span
- class="option">cleanHistoryOnStart</span> to <a
+ class="prop">cleanHistoryOnStart</span> to <a
href="manual/appenders.html#TimeBasedRollingPolicy">TimeBasedRollingPolicy</a>.
By setting this property to <code>true</code>, history removal
will work as expected even in the case of short lived
@@ -237,8 +226,6 @@
Pierre Queinnec.
</p>
-
-
<h3>September 21st, 2011 - Release of version 0.9.30</h3>
<p>Archive removal can now deal with prolonged periods of
@@ -281,15 +268,15 @@
reported by Josh Oddman.</p>
<p>It is now possible to specify multiple destination addresses
- separated by commas in the the <span class="option">to</span>
+ separated by commas in the the <span class="prop">to</span>
property of <code>SMTPAppender</code>. This fixes <a
href="http://jira.qos.ch/browse/LBCORE-213">LBCORE-213</a>
reported by Alexandre Garnier who also provided the relevant
patch. In previous versions of logback multiple destination
addresses could only be specified by using multiple <span
- class="option">to</span> properties. As of version 0.9.30 both
+ class="prop">to</span> properties. As of version 0.9.30 both
comma separated addresses and multiple <span
- class="option">to</span> properties are supported.
+ class="prop">to</span> properties are supported.
</p>
<p>When debug attribute is set to true within the
@@ -420,7 +407,7 @@
</p>
<p>The <a href="manual/appenders.html#smtpTo"><span
- class="option">to</span></a> option of SMTPAppender now admits a
+ class="prop">to</span></a> option of SMTPAppender now admits a
pattern and is evaluated dynamically.</p>
<p><code>TeeServletInputStream</code> no longer chokes on input
@@ -740,7 +727,7 @@ ALTER TABLE logging_event ADD arg3 VARCHAR(254);</pre>
special.
</p>
- <p>The <span class="option">CharsetEncoder</span> property in
+ <p>The <span class="prop">CharsetEncoder</span> property in
<code>SMTPAppender</code> can now be accessed and set from
configuration files. This fixes <a
href="http://jira.qos.ch/browse/LBCLASSIC-194">LBCLASSIC-194</a>.
diff --git a/logback-site/src/site/pages/templates/header.js b/logback-site/src/site/pages/templates/header.js
index 96a6a46..6bfd5f4 100644
--- a/logback-site/src/site/pages/templates/header.js
+++ b/logback-site/src/site/pages/templates/header.js
@@ -5,7 +5,7 @@ document.write('</a></td>')
document.write('<td> </td>');
-document.write('<td width=70%"><span style="font-weight: bold; font-size: medium; background-color: #FFDDDD">Due to an error, <a href="http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/maven-metadata…">metadata</a> for logback on Maven central only mentions version 1.0.2. As such such, "mvn" can no longer fetch earlier versions of logback from Maven central. Until this issue is resolved, one simple workaround is to upgrade to logback 1.0.2 in your project' pom.xml file. Please also vote for <a href="https://issues.sonatype.org/browse/OSSRH-3437">OSSRH-3437</a>.</span></td>');
+document.write('<td width="70%" style="padding-right: 10em;"><span style="font-weight: bold; font-size: medium; background-color: #FFF8E8; ">Due to an error, <a href="http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/maven-metadata…">metadata</a> for logback on Maven central only mentions versions 1.0.2 and 1.0.3. It follows that "mvn" can no longer fetch earlier versions of logback artifacts from Maven central. Until this issue is resolved, one simple workaround is to upgrade your project's <em>pom.xml</em> file to use logback version 1.0.3 (or 1.0.2). Please also vote for <a href="https://issues.sonatype.org/browse/OSSRH-3437">OSSRH-3437</a>.</span></td>');
document.write('</tr></table>')
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/classic/BasicConfigurator.java | 1 -
.../classic/encoder/PatternLayoutEncoder.java | 2 +-
.../logback/classic/jul/LevelChangePropagator.java | 2 +-
.../classic/encoder/PatternLayoutEncoderTest.java | 2 +-
.../lbcore243/PerformanceComparatorLogback.java | 7 --
.../lbcore243/logback_without_immediateFlush.xml | 3 +-
.../classic/net/SMTPAppender_GreenTest.java | 2 +-
.../logback/core/pattern/PatternLayoutBase.java | 2 +-
.../core/pattern/PatternLayoutEncoderBase.java | 2 +-
.../core/pattern/parser/SamplePatternLayout.java | 1 -
logback-site/src/site/pages/manual/appenders.html | 18 ++++--
logback-site/src/site/pages/manual/encoders.html | 69 ++++++++++++++++++--
logback-site/src/site/pages/news.html | 61 +++++++-----------
logback-site/src/site/pages/templates/header.js | 2 +-
14 files changed, 110 insertions(+), 64 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCLASSIC-256) java.util.logging propagated level changes are lost because of race condition with garbage collection
by Samuel Stanojevic (JIRA) 03 May '12
by Samuel Stanojevic (JIRA) 03 May '12
03 May '12
java.util.logging propagated level changes are lost because of race condition with garbage collection
-----------------------------------------------------------------------------------------------------
Key: LBCLASSIC-256
URL: http://jira.qos.ch/browse/LBCLASSIC-256
Project: logback-classic
Issue Type: Bug
Affects Versions: 0.9.28
Environment: win7 64-bit, bootstrapped in a Tomcat server
Reporter: Samuel Stanojevic
Assignee: Logback dev list
Attachments: LevelChangePropagator.java
I have bootstrapped logback in my Tomcat server, and have setup JUL to redirect logging requests to SLF4J by adding the following in my logging.properties:
.handlers = org.slf4j.bridge.SLF4JBridgeHandler
Anyways, my setup works pretty nicely. The problem is when I try to activate the JUL LevelChangePropagator, the info doesn't quite propagate as expected.
Here is my config:
<configuration debug="true">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<target>System.out</target>
</appender>
<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>
<logger name="test.propagation" level="TRACE"/> <!-- race condition here? -->
</configuration>
The problem is that if my app tries to do:
java.util.logging.Logger.getLogger("test.propagation").fine("hello world");
..., it doesn't print.
I have confirmed that the bug is because, even though the LevelChangePropagator class does propagate the level change info to JUL, it fails to keep a strong reference to the logger that it just changed. By not keeping a strong reference, and because the JUL LogManager only keeps WeakReferences to loggers, then the GC has time to clear out the change before the app's first attempt to use the logger. (see java.util.logging.LogManager#addLogger where the javadoc says "The application should retain its own reference to the Logger object to avoid it being garbage collected. The LogManager may only retain a weak reference")
To test my hunch, I patched the LevelChangePropagator class by adding a global hashset of java.util.logging.Logger, and I systematically add the loggers to the hashset in the method "propagate(logger,level)". After this patch, my logging started working as expected.
My fix may not be the best, and may have implications that I did not think about, but I think something along those lines needs to be done to fix the bug.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
5
7

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.2-7-g0a2446b
by git-noreply@pixie.qos.ch 03 May '12
by git-noreply@pixie.qos.ch 03 May '12
03 May '12
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, master has been updated
via 0a2446b85f3ba811d9cbd153f3e591ca44ea4e0f (commit)
from d903644be47ceaf38b437a921c3163a2335d9d5e (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=0a2446b85f3ba811d9cbd153…
http://github.com/ceki/logback/commit/0a2446b85f3ba811d9cbd153f3e591ca44ea4…
commit 0a2446b85f3ba811d9cbd153f3e591ca44ea4e0f
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu May 3 18:29:18 2012 +0200
Fix http://jira.qos.ch/browse/LBCLASSIC-256
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
index 05ffa57..3f8cb7d 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/jul/LevelChangePropagator.java
@@ -21,7 +21,9 @@ import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.spi.LifeCycle;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.logging.LogManager;
@@ -30,8 +32,8 @@ import java.util.logging.LogManager;
*/
public class LevelChangePropagator extends ContextAwareBase implements LoggerContextListener, LifeCycle {
+ private Set julLoggerSet = new HashSet();
boolean isStarted = false;
-
boolean resetJUL = false;
public void setResetJUL(boolean resetJUL) {
@@ -58,6 +60,9 @@ public class LevelChangePropagator extends ContextAwareBase implements LoggerCon
private void propagate(Logger logger, Level level) {
addInfo("Propagating " + level + " level on " + logger + " onto the JUL framework");
java.util.logging.Logger julLogger = JULHelper.asJULLogger(logger);
+ // prevent garbage collection of jul loggers levels were propagated to
+ // see also http://jira.qos.ch/browse/LBCLASSIC-256
+ julLoggerSet.add(julLogger);
java.util.logging.Level julLevel = JULHelper.asJULLevel(level);
julLogger.setLevel(julLevel);
}
-----------------------------------------------------------------------
Summary of changes:
.../logback/classic/jul/LevelChangePropagator.java | 7 ++++++-
1 files changed, 6 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 master updated. v_1.0.2-6-gd903644
by git-noreply@pixie.qos.ch 03 May '12
by git-noreply@pixie.qos.ch 03 May '12
03 May '12
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, master has been updated
via d903644be47ceaf38b437a921c3163a2335d9d5e (commit)
from df62eebfa7bbd7053a84aca740ed8aa63c548315 (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=d903644be47ceaf38b437a92…
http://github.com/ceki/logback/commit/d903644be47ceaf38b437a921c3163a2335d9…
commit d903644be47ceaf38b437a921c3163a2335d9d5e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu May 3 18:27:57 2012 +0200
Fix http://jira.qos.ch/browse/LBCLASSIC-256
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/jul/LevelChangePropagatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/jul/LevelChangePropagatorTest.java
index 9f6fc56..ddfe00c 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/jul/LevelChangePropagatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/jul/LevelChangePropagatorTest.java
@@ -16,12 +16,14 @@ package ch.qos.logback.classic.jul;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.testUtil.RandomUtil;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class LevelChangePropagatorTest {
+ int rand = RandomUtil.getPositiveInt();
LoggerContext loggerContext = new LoggerContext();
LevelChangePropagator levelChangePropagator = new LevelChangePropagator();
@@ -38,15 +40,12 @@ public class LevelChangePropagatorTest {
java.util.logging.Level julLevel = JULHelper.asJULLevel(level);
assertEquals(julLevel, julLogger.getLevel());
-
-
}
@Test
public void smoke() {
checkLevelChange("a", Level.INFO);
checkLevelChange("a.b", Level.DEBUG);
-
}
@Test
@@ -54,4 +53,17 @@ public class LevelChangePropagatorTest {
checkLevelChange(Logger.ROOT_LOGGER_NAME, Level.TRACE);
}
+ // see http://jira.qos.ch/browse/LBCLASSIC-256
+ @Test
+ public void gc() {
+ Logger logger = loggerContext.getLogger("gc"+rand);
+ logger.setLevel(Level.INFO);
+ // invoke GC so that the relevant julLogger can be garbage collected.
+ System.gc();
+ java.util.logging.Logger julLogger = JULHelper.asJULLogger(logger);
+ java.util.logging.Level julLevel = JULHelper.asJULLevel(Level.INFO);
+
+ assertEquals(julLevel, julLogger.getLevel());
+ }
+
}
-----------------------------------------------------------------------
Summary of changes:
.../classic/jul/LevelChangePropagatorTest.java | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCORE-243) Return ImmediateFlush and perhaps buffering options to FileAppender
by Petr H (JIRA) 03 May '12
by Petr H (JIRA) 03 May '12
03 May '12
Return ImmediateFlush and perhaps buffering options to FileAppender
-------------------------------------------------------------------
Key: LBCORE-243
URL: http://jira.qos.ch/browse/LBCORE-243
Project: logback-core
Issue Type: Improvement
Components: Appender
Affects Versions: 1.0.0
Reporter: Petr H
Assignee: Logback dev list
Based on the "log4j performance comparison" discussion in the logback-user mailing list:
http://old.nabble.com/log4j-performance-comparison-td31183677.html
I'd like to see at least the ImmediateFlush option back as it causes really big difference in writing performance at our systems with heavy logging activity.
Last logback release with ImmediateFlush option is 0.9.18 and this is the one we have to stay at due to performance reasons. We can't afford to upgrade to later logback release or switch ImmediateFlush to true as it makes some of our systems practically unusable.
The best option seems to be the use of FileWriter with the possibility to set the ImmediateFlush option and also buffering (wrapping with BufferedWriter and use of BufferedIO + BufferSize options) can help a little.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
2
2

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.2-5-gdf62eeb
by git-noreply@pixie.qos.ch 03 May '12
by git-noreply@pixie.qos.ch 03 May '12
03 May '12
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, master has been updated
via df62eebfa7bbd7053a84aca740ed8aa63c548315 (commit)
via 174573f53b1e2cc878ac846efb3c83abede1574b (commit)
via 09aee6ec5a27a4be4ae7250ffeed2b058c812346 (commit)
from 8b064299b7d22094542777b0617290e3e4625850 (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=df62eebfa7bbd7053a84aca7…
http://github.com/ceki/logback/commit/df62eebfa7bbd7053a84aca740ed8aa63c548…
commit df62eebfa7bbd7053a84aca740ed8aa63c548315
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu May 3 15:34:32 2012 +0200
fix LBCORE-243
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
index 5f15b8e..f186f9d 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
@@ -1,12 +1,5 @@
package ch.qos.logback.classic.issue.lbcore243;
-/**
- * Created with IntelliJ IDEA.
- * User: ceki
- * Date: 27.04.12
- * Time: 00:05
- * To change this template use File | Settings | File Templates.
- */
public class Common {
// How many times should we try to log:
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
index 0be7c6f..e1e5c0d 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
@@ -1,12 +1,6 @@
package ch.qos.logback.classic.issue.lbcore243;
-/**
- * Created with IntelliJ IDEA.
- * User: ceki
- * Date: 26.04.12
- * Time: 21:52
- * To change this template use File | Settings | File Templates.
- */
+
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
@@ -14,6 +8,10 @@ import org.apache.log4j.xml.DOMConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+// WARNING This code compiles but does not measure anything useful because log4j-over-slf4j is a dependency. Log4j
+// should be used instead
+
public class PerformanceComparatorLog4j {
static org.apache.log4j.Logger log4jlogger = org.apache.log4j.Logger.getLogger(PerformanceComparatorLog4j.class);
@@ -24,7 +22,6 @@ public class PerformanceComparatorLog4j {
// Let's run once for Just In Time compiler
log4jDirectDebugCall();
-
System.out.println("###############################################");
System.out.println("Log4j without immediate flush: " + log4jDirectDebugCall()+ " nanos per call");
System.out.println("###############################################");
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
index b6c40fb..aacc7c6 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
@@ -14,6 +14,10 @@ import ch.qos.logback.core.joran.spi.JoranException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+// Results AMD Phenom II X6 1110T processor and SSD disk
+//Logback with immediate flush: 8356 nanos per call
+//Logback without immediate flush: 1758 nanos per call
+
public class PerformanceComparatorLogback {
static Logger logbacklogger = LoggerFactory.getLogger(PerformanceComparatorLogback.class);
@@ -21,8 +25,14 @@ public class PerformanceComparatorLogback {
initLogbackWithoutImmediateFlush();
logbackParametrizedDebugCall();
+ initLogbackWithImmediateFlush();
+ logbackParametrizedDebugCall();
System.out.println("###############################################");
+ System.out.println("Logback with immediate flush: " + logbackParametrizedDebugCall() + " nanos per call");
+
+ initLogbackWithoutImmediateFlush();
System.out.println("Logback without immediate flush: " + logbackParametrizedDebugCall() + " nanos per call");
+
System.out.println("###############################################");
}
@@ -38,13 +48,21 @@ public class PerformanceComparatorLogback {
static String DIR_PREFIX = "src/test/java/ch/qos/logback/classic/issue/lbcore243/";
- private static void initLogbackWithoutImmediateFlush() throws JoranException {
+
+ static void configure(String file) throws JoranException {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator jc = new JoranConfigurator();
- jc.setContext(loggerContext);
- loggerContext.reset();
- jc.doConfigure(DIR_PREFIX + "logback.xml");
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(loggerContext);
+ loggerContext.reset();
+ jc.doConfigure(file);
}
+ private static void initLogbackWithoutImmediateFlush() throws JoranException {
+ configure(DIR_PREFIX + "logback_without_immediateFlush.xml");
+ }
+
+ private static void initLogbackWithImmediateFlush() throws JoranException {
+ configure(DIR_PREFIX + "logback_with_immediateFlush.xml");
+ }
}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_with_immediateFlush.xml
similarity index 74%
copy from logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
copy to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_with_immediateFlush.xml
index c4978f7..ec34915 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_with_immediateFlush.xml
@@ -1,8 +1,8 @@
<configuration>
<appender name="TestLogfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>d:/test/logback_without_flush.log</file>
+ <file>target/test-output/perf/logback_with_flush.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>d:/test/logback_without_flush.log.%i</fileNamePattern>
+ <fileNamePattern>target/test-output/perf/logback_with_flush.log.%i</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
@@ -11,7 +11,7 @@
</triggeringPolicy>
<encoder>
<Pattern>%d{ISO8601} %5p [%t] %c - %m%n</Pattern>
- <immediateFlush>false</immediateFlush>
+ <immediateFlush>true</immediateFlush>
<!--<charset>UTF-8</charset>-->
</encoder>
</appender>
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
similarity index 79%
rename from logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
rename to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
index c4978f7..3d4f49e 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
@@ -1,8 +1,8 @@
<configuration>
<appender name="TestLogfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>d:/test/logback_without_flush.log</file>
+ <file>target/test-output/perf/logback_without_flush.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>d:/test/logback_without_flush.log.%i</fileNamePattern>
+ <fileNamePattern>target/test-output/perf/logback_without_flush.log.%i</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>1</maxIndex>
</rollingPolicy>
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
index 2784676..0ac7d31 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
@@ -26,6 +26,7 @@ public class EchoEncoder<E> extends EncoderBase<E> {
public void doEncode(E event) throws IOException {
String val = event + CoreConstants.LINE_SEPARATOR;
outputStream.write(val.getBytes());
+ // necessary if ResilientFileOutputStream is buffered
outputStream.flush();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
index 1dee67a..fa5cfab 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutBase.java
@@ -34,7 +34,7 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
Map<String, String> instanceConverterMap = new HashMap<String, String>();
- protected boolean outputPatternAsPresentationHeader = true;
+ protected boolean outputPatternAsHeader = true;
/**
* Concrete implementations of this class are responsible for elaborating the
@@ -144,20 +144,19 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
return CoreConstants.EMPTY_STRING;
}
- public boolean isOutputPatternAsPresentationHeader() {
- return outputPatternAsPresentationHeader;
+ public boolean isOutputPatternAsHeader() {
+ return outputPatternAsHeader;
}
- public void setOutputPatternAsPresentationHeader(boolean outputPatternAsPresentationHeader) {
- this.outputPatternAsPresentationHeader = outputPatternAsPresentationHeader;
+ public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
+ this.outputPatternAsHeader = outputPatternAsHeader;
}
-
+
@Override
public String getPresentationHeader() {
- if(outputPatternAsPresentationHeader)
+ if(outputPatternAsHeader)
return getPresentationHeaderPrefix()+pattern;
else
return super.getPresentationHeader();
-
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
index eaccd55..a094dcc 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/PatternLayoutEncoderBase.java
@@ -19,7 +19,9 @@ import ch.qos.logback.core.encoder.LayoutWrappingEncoder;
public class PatternLayoutEncoderBase<E> extends LayoutWrappingEncoder<E> {
String pattern;
- protected boolean outputPatternAsPresentationHeader = true;
+
+ // due to popular demand outputPatternAsHeader is set to false by default
+ protected boolean outputPatternAsHeader = false;
public String getPattern() {
return pattern;
@@ -29,12 +31,32 @@ public class PatternLayoutEncoderBase<E> extends LayoutWrappingEncoder<E> {
this.pattern = pattern;
}
+ public boolean isOutputPatternAsHeader() {
+ return outputPatternAsHeader;
+ }
+
+
+ /**
+ * Print the pattern string as a header in log files
+ *
+ * @param outputPatternAsHeader
+ * @since 1.0.3
+ */
+ public void setOutputPatternAsHeader(boolean outputPatternAsHeader) {
+ this.outputPatternAsHeader = outputPatternAsHeader;
+ }
+
+
public boolean isOutputPatternAsPresentationHeader() {
- return outputPatternAsPresentationHeader;
+ return outputPatternAsHeader;
}
- public void setOutputPatternAsPresentationHeader(boolean outputPatternAsPresentationHeader) {
- this.outputPatternAsPresentationHeader = outputPatternAsPresentationHeader;
+ /**
+ * @deprecated replaced by {@link #setOutputPatternAsHeader(boolean)}
+ */
+ public void setOutputPatternAsPresentationHeader(boolean outputPatternAsHeader) {
+ addWarn("outputPatternAsPresentationHeader option is deprecated. Use outputPatternAsHeader option instead.");
+ this.outputPatternAsHeader = outputPatternAsHeader;
}
@Override
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 86f640d..26126fe 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -8,11 +8,12 @@
<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" />
-
+ <link rel="stylesheet" type="text/css" href="css/prettify.css" media="screen" />
</head>
- <body>
- <script type="text/javascript">prefix='';</script>
+ <body onload="prettyPrint()">
+ <script type="text/javascript">prefix='';</script>
+ <script type="text/javascript" src="js/prettify.js"></script>
<script src="templates/header.js" type="text/javascript"></script>
<div id="left">
<noscript>Please turn on Javascript to view this menu</noscript>
@@ -29,20 +30,35 @@
<hr width="80%" align="center" />
- <h3>26th of April, 2012 - Release of version 1.0.2</h3>
+ <h3>3rd of May, 2012 - Release of version 1.0.3</h3>
- <div style="border: 1px solid #F44; background-color: #FED; padding-left: 1ex; padding-right: 1ex;">
+ <p><code>PatternLayoutEncoder</code> now admits the <span
+ class="option">immediateFlush</span> option (set to true by
+ default). By setting this option to false, logging throughput can
+ be quadrupled, although your mileage may vary. This option was
+ requested in <a
+ href="http://jira.qos.ch/browse/LBCORE-243">LBCORE-243</a>.
+ </p>
- <h4>Breaking change: <code>PatternLayout</code> will now output
- its pattern at the top of log files</h4>
- <p>In order to facilitate parsing of log files, logback now
- inserts the pattern used for the log output at the top of each log
- file. This feature was requested by James Strachan in <a
+ <p>In order to facilitate parsing of log files, logback can now
+ insert the pattern used for the log output at the top of log
+ files. This feature was requested by James Strachan in <a
href="http://jira.qos.ch/browse/LBCORE-234">LBCORE-234</a>.
- </p>
+ However, this feature is <b>not</b> enabled by default. It can be
+ enabled by setting the <span
+ class="option">outputPatternAsHeader</span> option to 'true' for
+ the relevant encoder. Here is an example:</p>
- <p>Here an example:</p>
+<pre class="prettyprint"><appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>foo.log</file>
+ <encoder>
+ <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
+ <b><outputPatternAsHeader>true</outputPatternAsHeader></b>
+ </encoder>
+</appender></pre>
+
+ <p>This will result output akin to the following in the log file:</p>
<pre>#logback.classic pattern: %d [%thread] %-5level %logger{36} - %msg%n
2012-04-26 14:54:38,461 [main] DEBUG com.foo.App - Hello world
@@ -52,17 +68,18 @@
<p>The line starting with "#logback.classic pattern" is newly
inserted pattern line.</p>
- <p>If you wish to disable printing this line, set the
- <span class="option">outputPatternAsPresentationHeader</span> option to false for the
- relevant encoder. Here is an example:</p>
+ <h3>26th of April, 2012 - Release of version 1.0.2</h3>
+
+ <div style="border: 1px solid #F44; background-color: #FED; padding-left: 1ex; padding-right: 1ex;">
+
+ <h4><span class="label">Breaking change partially reverted in
+ 1.0.3</span><br/>By default <code>PatternLayout</code> will now output
+ its pattern at the top of log files</h4>
+
+ <p>This feature, although still available, is no longer enabled by
+ default. See release 1.0.3 for details.
+ </p>
-<pre><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
- <b><-- do not print pattern as a header --></b>
- <b><outputPatternAsPresentationHeader>false</outputPatternAsPresentationHeader></b>
- </encoder>
-</appender> </pre>
</div>
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=174573f53b1e2cc878ac846e…
http://github.com/ceki/logback/commit/174573f53b1e2cc878ac846efb3c83abede15…
commit 174573f53b1e2cc878ac846efb3c83abede1574b
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed May 2 21:55:07 2012 +0200
Fixing LBCORE-243 by reintroducing buffered streaming and immediate flush as an option
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
new file mode 100644
index 0000000..5f15b8e
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
@@ -0,0 +1,15 @@
+package ch.qos.logback.classic.issue.lbcore243;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: ceki
+ * Date: 27.04.12
+ * Time: 00:05
+ * To change this template use File | Settings | File Templates.
+ */
+public class Common {
+
+ // How many times should we try to log:
+ static int loop = 800*1000;
+
+}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
new file mode 100644
index 0000000..0be7c6f
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
@@ -0,0 +1,52 @@
+package ch.qos.logback.classic.issue.lbcore243;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: ceki
+ * Date: 26.04.12
+ * Time: 21:52
+ * To change this template use File | Settings | File Templates.
+ */
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.joran.spi.JoranException;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PerformanceComparatorLog4j {
+
+ static org.apache.log4j.Logger log4jlogger = org.apache.log4j.Logger.getLogger(PerformanceComparatorLog4j.class);
+
+ public static void main(String[] args) throws JoranException, InterruptedException {
+ initLog4jWithoutImmediateFlush();
+
+ // Let's run once for Just In Time compiler
+ log4jDirectDebugCall();
+
+
+ System.out.println("###############################################");
+ System.out.println("Log4j without immediate flush: " + log4jDirectDebugCall()+ " nanos per call");
+ System.out.println("###############################################");
+ }
+
+ private static long log4jDirectDebugCall() {
+ Integer j = new Integer(2);
+ long start = System.nanoTime();
+ for (int i = 0; i < Common.loop; i++) {
+ log4jlogger.debug("SEE IF THIS IS LOGGED " + j + ".");
+ }
+ return (System.nanoTime() - start) / Common.loop;
+ }
+
+ static String DIR_PREFIX = "src/test/java/ch/qos/logback/classic/issue/lbcore243/";
+
+ static void initLog4jWithoutImmediateFlush() {
+ DOMConfigurator domConfigurator = new DOMConfigurator();
+ domConfigurator.configure(DIR_PREFIX+"log4j_without_immediateFlush.xml");
+ }
+ static void initLog4jWithImmediateFlush() {
+ DOMConfigurator domConfigurator = new DOMConfigurator();
+ domConfigurator.configure(DIR_PREFIX+"log4j_with_immediateFlush.xml");
+ }
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
new file mode 100644
index 0000000..b6c40fb
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
@@ -0,0 +1,50 @@
+package ch.qos.logback.classic.issue.lbcore243;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: ceki
+ * Date: 26.04.12
+ * Time: 21:52
+ * To change this template use File | Settings | File Templates.
+ */
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.joran.spi.JoranException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PerformanceComparatorLogback {
+ static Logger logbacklogger = LoggerFactory.getLogger(PerformanceComparatorLogback.class);
+
+ public static void main(String[] args) throws JoranException, InterruptedException {
+ initLogbackWithoutImmediateFlush();
+ logbackParametrizedDebugCall();
+
+ System.out.println("###############################################");
+ System.out.println("Logback without immediate flush: " + logbackParametrizedDebugCall() + " nanos per call");
+ System.out.println("###############################################");
+ }
+
+ private static long logbackParametrizedDebugCall() {
+
+ Integer j = new Integer(2);
+ long start = System.nanoTime();
+ for (int i = 0; i < Common.loop; i++) {
+ logbacklogger.debug("SEE IF THIS IS LOGGED {}.", j);
+ }
+ return (System.nanoTime() - start) / Common.loop;
+ }
+
+ static String DIR_PREFIX = "src/test/java/ch/qos/logback/classic/issue/lbcore243/";
+
+ private static void initLogbackWithoutImmediateFlush() throws JoranException {
+ LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(loggerContext);
+ loggerContext.reset();
+ jc.doConfigure(DIR_PREFIX + "logback.xml");
+ }
+
+
+}
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_with_immediateFlush.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_with_immediateFlush.xml
new file mode 100644
index 0000000..d885b58
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_with_immediateFlush.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="TestLogfile" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="d:/test/log4j_with_flush.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="maxBackupIndex" value="1"/>
+ <param name="immediateFlush" value="true"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c %X{transactionId} - %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="debug"/>
+ <appender-ref ref="TestLogfile"/>
+ </root>
+</log4j:configuration>
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_without_immediateFlush.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_without_immediateFlush.xml
new file mode 100644
index 0000000..51ed4f0
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_without_immediateFlush.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="TestLogfile" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="c:/test/log4j_without_flush.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="maxBackupIndex" value="1"/>
+ <param name="immediateFlush" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ISO8601} %5p [%t] %c %X{transactionId} - %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="debug"/>
+ <appender-ref ref="TestLogfile"/>
+ </root>
+</log4j:configuration>
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
new file mode 100644
index 0000000..c4978f7
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback.xml
@@ -0,0 +1,22 @@
+<configuration>
+ <appender name="TestLogfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>d:/test/logback_without_flush.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>d:/test/logback_without_flush.log.%i</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>1</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>1000KB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <Pattern>%d{ISO8601} %5p [%t] %c - %m%n</Pattern>
+ <immediateFlush>false</immediateFlush>
+ <!--<charset>UTF-8</charset>-->
+ </encoder>
+ </appender>
+ <root>
+ <level value="debug"/>
+ <appender-ref ref="TestLogfile"/>
+ </root>
+</configuration>
\ No newline at end of file
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
index 7e72707..2784676 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/EchoEncoder.java
@@ -26,6 +26,7 @@ public class EchoEncoder<E> extends EncoderBase<E> {
public void doEncode(E event) throws IOException {
String val = event + CoreConstants.LINE_SEPARATOR;
outputStream.write(val.getBytes());
+ outputStream.flush();
}
public void close() throws IOException {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java b/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java
index c030ee1..e7ac7aa 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/encoder/LayoutWrappingEncoder.java
@@ -27,13 +27,33 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
/**
* The charset to use when converting a String into bytes.
- * <p>
+ * <p/>
* By default this property has the value
- * <code>null</null> which corresponds to
+ * <code>null</null> which corresponds to
* the system's default charset.
*/
private Charset charset;
+ private boolean immediateFlush = true;
+
+
+ /**
+ * Sets the immediateFlush option. The default value for immediateFlush is 'true'. If set to true,
+ * the doEncode() method will immediately flush the underlying OutputStream. Although immediate flushing
+ * is safer, it also significantly degrades logging throughput.
+ *
+ * @since 1.0.3
+ */
+ public void setImmediateFlush(boolean immediateFlush) {
+ this.immediateFlush = immediateFlush;
+ }
+
+
+ public boolean isImmediateFlush() {
+ return immediateFlush;
+ }
+
+
public Layout<E> getLayout() {
return layout;
}
@@ -49,11 +69,11 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
/**
* Set the charset to use when converting the string returned by the layout
* into bytes.
- * <p>
+ * <p/>
* By default this property has the value
- * <code>null</null> which corresponds to
+ * <code>null</null> which corresponds to
* the system's default charset.
- *
+ *
* @param charset
*/
public void setCharset(Charset charset) {
@@ -94,7 +114,6 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
outputStream.write(convertToBytes(sb.toString()));
outputStream.flush();
}
-
}
}
@@ -106,7 +125,7 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
return s.getBytes(charset.name());
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(
- "An existing charset cannot possibly be unsupported.");
+ "An existing charset cannot possibly be unsupported.");
}
}
}
@@ -114,7 +133,8 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
public void doEncode(E event) throws IOException {
String txt = layout.doLayout(event);
outputStream.write(convertToBytes(txt));
- outputStream.flush();
+ if (immediateFlush)
+ outputStream.flush();
}
public boolean isStarted() {
@@ -127,6 +147,12 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
public void stop() {
started = false;
+ if(outputStream != null) {
+ try {
+ outputStream.flush();
+ } catch (IOException e) {
+ }
+ }
}
private void appendIfNotNull(StringBuilder sb, String s) {
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 60c7245..9710042 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
@@ -13,21 +13,20 @@
*/
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.io.*;
import java.nio.channels.FileChannel;
public class ResilientFileOutputStream extends ResilientOutputStreamBase {
- File file;
+ private File file;
+ private FileOutputStream fos;
+
public ResilientFileOutputStream(File file, boolean append)
throws FileNotFoundException {
this.file = file;
- this.os = new FileOutputStream(file, append);
+ fos = new FileOutputStream(file, append);
+ this.os = new BufferedOutputStream(fos);
this.presumedClean = true;
}
@@ -35,7 +34,6 @@ public class ResilientFileOutputStream extends ResilientOutputStreamBase {
if (os == null) {
return null;
}
- final FileOutputStream fos = (FileOutputStream) os;
return fos.getChannel();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java
index c665dc1..088ead5 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.java
@@ -16,6 +16,7 @@ package ch.qos.logback.core.rolling;
import java.io.File;
import ch.qos.logback.core.util.FileSize;
+import ch.qos.logback.core.util.InvocationGate;
/**
* SizeBasedTriggeringPolicy looks at size of the file being currently written
@@ -46,17 +47,14 @@ public class SizeBasedTriggeringPolicy<E> extends TriggeringPolicyBase<E> {
setMaxFileSize(maxFileSize);
}
- // IMPORTANT: This field can be updated by multiple threads. It follows that
- // its values may *not* be incremented sequentially. However, we don't care
- // about the actual value of the field except that from time to time the
- // expression (invocationCounter++ & 0xF) == 0xF) should be true.
- private int invocationCounter = 0xF;
+ private InvocationGate invocationGate = new InvocationGate();
public boolean isTriggeringEvent(final File activeFile, final E event) {
- // for performance reasons, check for changes every 16 invocations
- if (((invocationCounter++) & 0xF) != 0xF) {
+ if(invocationGate.skipFurtherWork())
return false;
- }
+
+ long now = System.currentTimeMillis();
+ invocationGate.updateMaskIfNecessary(now);
return (activeFile.length() >= maxFileSize.getSize());
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java b/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java
new file mode 100644
index 0000000..8e00df5
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.java
@@ -0,0 +1,48 @@
+package ch.qos.logback.core.util;
+
+/**
+ * This class serves as a gateway for invocations of a "costly" operation on a critical execution path.
+ *
+ * @author Ceki Gülcü
+ */
+public class InvocationGate {
+
+ // experiments indicate that even for the most CPU intensive applications with 200 or more threads MASK
+ // values in the order of 0xFFFF is appropriate
+ private static final int MAX_MASK = 0xFFFF;
+
+ private volatile long mask = 0xF;
+ private volatile long lastMaskCheck = System.currentTimeMillis();
+
+
+ // IMPORTANT: This field can be updated by multiple threads. It follows that
+ // its values may *not* be incremented sequentially. However, we don't care
+ // about the actual value of the field except that from time to time the
+ // expression (invocationCounter++ & mask) == mask) should be true.
+ private long invocationCounter = 0;
+
+
+ // if less than thresholdForMaskIncrease milliseconds elapse between invocations of updateMaskIfNecessary()
+ // method, then the mask should be increased
+ private static final long thresholdForMaskIncrease = 100;
+
+ // if more than thresholdForMaskDecrease milliseconds elapse between invocations of updateMaskIfNecessary() method,
+ // then the mask should be decreased
+ private final long thresholdForMaskDecrease = thresholdForMaskIncrease*8;
+
+
+ public boolean skipFurtherWork() {
+ return ((invocationCounter++) & mask) != mask;
+ }
+
+ // update the mask so as to execute change detection code about once every 100 to 8000 milliseconds.
+ public void updateMaskIfNecessary(long now) {
+ final long timeElapsedSinceLastMaskUpdateCheck = now - lastMaskCheck;
+ lastMaskCheck = now;
+ if (timeElapsedSinceLastMaskUpdateCheck < thresholdForMaskIncrease && (mask < MAX_MASK)) {
+ mask = (mask << 1) | 1;
+ } else if (timeElapsedSinceLastMaskUpdateCheck > thresholdForMaskDecrease) {
+ mask = mask >>> 2;
+ }
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
index 88d4de9..40a99d7 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/FileAppenderResilienceTest.java
@@ -17,6 +17,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;
+import ch.qos.logback.core.util.StatusPrinter;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -86,8 +87,9 @@ public class FileAppenderResilienceTest {
double bestCaseSuccessRatio = 1/delayCoefficient;
double lossinessFactor = 0.8;
+
ResilienceUtil
- .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * lossinessFactor);
+ .verify(logfileStr, "^hello (\\d{1,5})$", runner.getCounter(), bestCaseSuccessRatio * lossinessFactor);
}
private void closeLogFileOnPurpose() throws IOException {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java b/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java
index fc4c2ab..c051065 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/util/ResilienceUtil.java
@@ -39,7 +39,7 @@ public class ResilienceUtil {
totalLines++;
String g = m.group(1);
int num = Integer.parseInt(g);
- if(num != oldNum+1) {
+ if(oldNum != -1 && num != oldNum+1) {
gaps++;
}
oldNum = num;
@@ -51,8 +51,8 @@ public class ResilienceUtil {
int lowerLimit = (int) (totalSteps*successRatioLowerBound);
assertTrue("totalLines="+totalLines+" less than "+lowerLimit, totalLines > lowerLimit);
- // we want some gaps which indicate recuperation
- assertTrue("gaps="+gaps+" less than 3", gaps >= 3);
+ // we want at least one gap indicating recuperation
+ assertTrue("gaps="+gaps+" less than 1", gaps >= 1);
}
}
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeBasedRolling_STest.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeBasedRolling_STest.scala
index ebeff2b..c9002ad 100644
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeBasedRolling_STest.scala
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/SizeBasedRolling_STest.scala
@@ -80,6 +80,7 @@ class SizeBasedRolling_STest extends RollingScaffolding {
Thread.sleep(10)
rfa.doAppend(prefix + i)
}
+ rfa.stop()
existenceCheck(expectedFilenameList)
reverseSortedContentCheck(randomOutputDir, runLength, prefix)
diff --git a/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala b/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
index ce09a22..64c7cad 100644
--- a/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
+++ b/logback-core/src/test/scala/ch/qos/logback/core/rolling/TimeBasedRolling_STest.scala
@@ -132,6 +132,7 @@ class TimeBasedRolling_STest extends RollingScaffolding {
incCurrentTime(100)
tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime)
}
+ rfa2.stop();
}
val NO_RESTART = 0
diff --git a/logback-site/src/site/pages/templates/header.js b/logback-site/src/site/pages/templates/header.js
index 4ee3250..96a6a46 100644
--- a/logback-site/src/site/pages/templates/header.js
+++ b/logback-site/src/site/pages/templates/header.js
@@ -5,7 +5,11 @@ document.write('</a></td>')
document.write('<td> </td>');
+document.write('<td width=70%"><span style="font-weight: bold; font-size: medium; background-color: #FFDDDD">Due to an error, <a href="http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/maven-metadata…">metadata</a> for logback on Maven central only mentions version 1.0.2. As such such, "mvn" can no longer fetch earlier versions of logback from Maven central. Until this issue is resolved, one simple workaround is to upgrade to logback 1.0.2 in your project' pom.xml file. Please also vote for <a href="https://issues.sonatype.org/browse/OSSRH-3437">OSSRH-3437</a>.</span></td>');
+
document.write('</tr></table>')
document.write('<div id="headerLine"></div>');
+
+
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=09aee6ec5a27a4be4ae7250f…
http://github.com/ceki/logback/commit/09aee6ec5a27a4be4ae7250ffeed2b058c812…
commit 09aee6ec5a27a4be4ae7250ffeed2b058c812346
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed May 2 21:53:30 2012 +0200
The ConsoleAppender created by BasicConfigurator should not output its pattern string
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
index 8c8de83..6890b9e 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
@@ -46,6 +46,7 @@ public class BasicConfigurator {
ca.setName("console");
PatternLayoutEncoder pl = new PatternLayoutEncoder();
pl.setContext(lc);
+ pl.setOutputPatternAsPresentationHeader(false);
pl.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");
pl.start();
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/classic/BasicConfigurator.java | 1 +
.../logback/classic/issue/lbcore243/Common.java | 8 ++
.../lbcore243/PerformanceComparatorLog4j.java | 49 ++++++++++++++
.../lbcore243/PerformanceComparatorLogback.java | 68 ++++++++++++++++++++
.../issue/lbcore243/log4j_with_immediateFlush.xml | 17 +++++
.../lbcore243/log4j_without_immediateFlush.xml | 17 +++++
.../lbcore243/logback_with_immediateFlush.xml | 22 ++++++
.../lbcore243/logback_without_immediateFlush.xml | 22 ++++++
.../ch/qos/logback/core/encoder/EchoEncoder.java | 2 +
.../core/encoder/LayoutWrappingEncoder.java | 42 ++++++++++--
.../logback/core/pattern/PatternLayoutBase.java | 15 ++--
.../core/pattern/PatternLayoutEncoderBase.java | 30 ++++++++-
.../core/recovery/ResilientFileOutputStream.java | 14 ++--
.../core/rolling/SizeBasedTriggeringPolicy.java | 14 ++--
.../ch/qos/logback/core/util/InvocationGate.java | 48 ++++++++++++++
.../logback/core/FileAppenderResilienceTest.java | 4 +-
.../ch/qos/logback/core/util/ResilienceUtil.java | 6 +-
.../core/rolling/SizeBasedRolling_STest.scala | 1 +
.../core/rolling/TimeBasedRolling_STest.scala | 1 +
logback-site/src/site/pages/news.html | 61 +++++++++++------
logback-site/src/site/pages/templates/header.js | 4 +
21 files changed, 384 insertions(+), 62 deletions(-)
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/Common.java
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLog4j.java
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/PerformanceComparatorLogback.java
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_with_immediateFlush.xml
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/log4j_without_immediateFlush.xml
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_with_immediateFlush.xml
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbcore243/logback_without_immediateFlush.xml
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/util/InvocationGate.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 master updated. v_1.0.2-2-g8b06429
by git-noreply@pixie.qos.ch 02 May '12
by git-noreply@pixie.qos.ch 02 May '12
02 May '12
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, master has been updated
via 8b064299b7d22094542777b0617290e3e4625850 (commit)
from 038fae3832917a45353459ce4e2eafaa4bd4d315 (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=8b064299b7d22094542777b0…
http://github.com/ceki/logback/commit/8b064299b7d22094542777b0617290e3e4625…
commit 8b064299b7d22094542777b0617290e3e4625850
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Wed May 2 10:45:40 2012 +0200
add blurb about outputPatternAsPresentationHeader option
diff --git a/logback-site/src/site/pages/manual/encoders.html b/logback-site/src/site/pages/manual/encoders.html
index ecd1000..5e95765 100644
--- a/logback-site/src/site/pages/manual/encoders.html
+++ b/logback-site/src/site/pages/manual/encoders.html
@@ -177,7 +177,7 @@ public class LayoutWrappingEncoder<E> extends EncoderBase<E> {
instances of <code>PatternLayout</code>.
</p>
- <p>As of logback version 9.9.19, whenever a
+ <p>As of logback version 0.9.19, whenever a
<code>FileAppender</code> or one of its sub-classes was configured
with a <code>PatternLayout</code>, a
<code>PatternLayoutEncoder</code> must be used instead. This is
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 7d9d0f4..86f640d 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -52,6 +52,18 @@
<p>The line starting with "#logback.classic pattern" is newly
inserted pattern line.</p>
+ <p>If you wish to disable printing this line, set the
+ <span class="option">outputPatternAsPresentationHeader</span> option to false for the
+ relevant encoder. Here is an example:</p>
+
+<pre><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d %-5level [%thread] %logger{0}: %msg%n</pattern>
+ <b><-- do not print pattern as a header --></b>
+ <b><outputPatternAsPresentationHeader>false</outputPatternAsPresentationHeader></b>
+ </encoder>
+</appender> </pre>
+
</div>
<p><code>ReconfigureOnChangeFilter</code> will avoid excessive
-----------------------------------------------------------------------
Summary of changes:
logback-site/src/site/pages/manual/encoders.html | 2 +-
logback-site/src/site/pages/news.html | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0