[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-73-ge85c622
Gitbot
git-noreply at pixie.qos.ch
Tue Mar 6 23:03:35 CET 2012
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 e85c6226ec0d00007c64508157d6054e07871406 (commit)
from 1169a18f6aac21cbbc1f2e60dfb7b75b2a2399a0 (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=e85c6226ec0d00007c64508157d6054e07871406
http://github.com/ceki/logback/commit/e85c6226ec0d00007c64508157d6054e07871406
commit e85c6226ec0d00007c64508157d6054e07871406
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Mar 6 23:02:16 2012 +0100
Setting the debug attribute to true in the <configuration> element now
registers a OnConsoleStatusListener with the StatusManager.
diff --git a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java b/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java
index 034494f..d58c8bf 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/joran/action/ConfigurationAction.java
@@ -13,6 +13,7 @@
*/
package ch.qos.logback.access.joran.action;
+import ch.qos.logback.core.status.OnConsoleStatusListener;
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.action.Action;
@@ -24,7 +25,6 @@ import ch.qos.logback.core.util.StatusPrinter;
public class ConfigurationAction extends Action {
static final String INTERNAL_DEBUG_ATTR = "debug";
- boolean debugMode = false;
public void begin(InterpretationContext ec, String name, Attributes attributes) {
String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
@@ -33,8 +33,8 @@ public class ConfigurationAction extends Action {
(debugAttrib == null) || debugAttrib.equals("")
|| debugAttrib.equals("false") || debugAttrib.equals("null")) {
addInfo("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
- } else {
- debugMode = true;
+ } else {
+ OnConsoleStatusListener.addNewInstanceToContext(context);
}
new ContextUtil(context).addHostNameAsProperty();
@@ -45,10 +45,6 @@ public class ConfigurationAction extends Action {
public void end(InterpretationContext ec, String name) {
addInfo("End of configuration.");
- if (debugMode) {
- StatusPrinter.print(context);
- }
-
ec.popObject();
}
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
index 6369585..42abe92 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConfigurationAction.java
@@ -13,6 +13,7 @@
*/
package ch.qos.logback.classic.joran.action;
+import ch.qos.logback.core.status.OnConsoleStatusListener;
import org.xml.sax.Attributes;
import ch.qos.logback.classic.LoggerContext;
@@ -29,7 +30,6 @@ public class ConfigurationAction extends Action {
static final String SCAN_ATTR = "scan";
static final String SCAN_PERIOD_ATTR = "scanPeriod";
- boolean debugMode = false;
long threshold = 0;
public void begin(InterpretationContext ec, String name, Attributes attributes) {
@@ -40,7 +40,7 @@ public class ConfigurationAction extends Action {
|| debugAttrib.equalsIgnoreCase("null")) {
addInfo(INTERNAL_DEBUG_ATTR + " attribute not set");
} else {
- debugMode = true;
+ OnConsoleStatusListener.addNewInstanceToContext(context);
}
processScanAttrib(attributes);
@@ -77,11 +77,7 @@ public class ConfigurationAction extends Action {
}
public void end(InterpretationContext ec, String name) {
- if (debugMode) {
- addInfo("End of configuration.");
- LoggerContext loggerContext = (LoggerContext) context;
- StatusPrinter.print(loggerContext, threshold);
- }
+ addInfo("End of configuration.");
ec.popObject();
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java
index cbe54f2..af85522 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/StatusListenerAction.java
@@ -33,9 +33,8 @@ public class StatusListenerAction extends Action {
inError = false;
String className = attributes.getValue(CLASS_ATTRIBUTE);
if (OptionHelper.isEmpty(className)) {
- addError(
- "Missing class name for statusListener. Near ["
- + name + "] line " + getLineNumber(ec));
+ addError("Missing class name for statusListener. Near ["
+ + name + "] line " + getLineNumber(ec));
inError = true;
return;
}
@@ -43,11 +42,11 @@ public class StatusListenerAction extends Action {
try {
statusListener = (StatusListener) OptionHelper.instantiateByClassName(
className, StatusListener.class, context);
- addInfo("Adding status listener of type ["+className+"]");
ec.getContext().getStatusManager().add(statusListener);
if (statusListener instanceof ContextAware) {
((ContextAware) statusListener).setContext(context);
}
+ addInfo("Added status listener of type [" + className + "]");
ec.pushObject(statusListener);
} catch (Exception e) {
inError = true;
@@ -70,8 +69,7 @@ public class StatusListenerAction extends Action {
}
Object o = ec.peekObject();
if (o != statusListener) {
- addWarn(
- "The object at the of the stack is not the statusListener pushed earlier.");
+ addWarn("The object at the of the stack is not the statusListener pushed earlier.");
} else {
ec.popObject();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java b/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java
index daea4be..9658fa1 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/OnConsoleStatusListener.java
@@ -13,6 +13,8 @@
*/
package ch.qos.logback.core.status;
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.spi.ContextAware;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.util.StatusPrinter;
@@ -80,4 +82,16 @@ public class OnConsoleStatusListener extends ContextAwareBase implements StatusL
public boolean isStarted() {
return isStarted;
}
+
+ /**
+ * This utility method adds a new OnConsoleStatusListener to the context passed as parameter.
+ *
+ * @param context
+ * @since 1.0.1
+ */
+ static public void addNewInstanceToContext(Context context) {
+ OnConsoleStatusListener onConsoleStatusListener = new OnConsoleStatusListener();
+ onConsoleStatusListener.setContext(context);
+ context.getStatusManager().add(onConsoleStatusListener);
+ }
}
diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html
index 0812333..df1679a 100644
--- a/logback-site/src/site/pages/manual/configuration.html
+++ b/logback-site/src/site/pages/manual/configuration.html
@@ -368,21 +368,24 @@ public class Foo {
</ol>
<p>If any of these two conditions is not fulfilled, Joran cannot
- interpret the <code>debug</code> attribute since the configuration file
- cannot be read. If the configuration file is found but is
- malformed, then logback will detect the error condition and
- automatically print its internal status on the console. However, if
- the configuration file cannot be found, logback will not automatically
- print its status data, since this is not necessarily an error condition. Programmatically invoking
+ interpret the <span class="attr">debug</span> attribute since the
+ configuration file cannot be read. If the configuration file is
+ found but is malformed, then logback will detect the error
+ condition and automatically print its internal status on the
+ console. However, if the configuration file cannot be found,
+ logback will not automatically print its status data, since this is
+ not necessarily an error condition. Programmatically invoking
<code>StatusPrinter.print()</code> as in the <em>MyApp2</em>
application above ensures that status information is always
printed.
</p>
- <p>It is strongly recommended to register a status listener,
- e.g. <code>OnConsoleStatusListener</code>, so that problems
- occurring during the lifetime of your application, well after
- logback is initialized, can be reported. See the section on <a
+ <p>As of version 1.0.1, setting the <span class="attr">debug</span>
+ attribute is equivalent to registering an
+ <code>OnConsoleStatusListener</code> with the
+ <code>StatusManager</code>. Thus, problems occurring during the
+ lifetime of your application, well after logback is initialized,
+ can be reported. Refer to the section on <a
href="#statusListener">status listeners</a> further below.</p>
<h3><a name="configFileProperty"
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 1dadd0d..851bf66 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -29,7 +29,16 @@
<hr width="80%" align="center" />
- <h3>xx of December, 2011 - Release of version 1.0.1</h3>
+ <h3>xx of March, 2012 - Release of version 1.0.1</h3>
+
+ <p>Setting the debug attribute to true in the
+ <code><configuration></code> element now registers a
+ <code>OnConsoleStatusListener</code> with the
+ <code>StatusManager</code>. Thus, problems occurring during the
+ lifetime of your application, well after logback is initialized,
+ can be reported. This results in a behavior closer to what users
+ expect.
+ </p>
<p>Added new property the <span
class="option">cleanHistoryOnStart</span> to <a
@@ -60,9 +69,9 @@
as reported by Chris Cheshire.
</p>
- <p>SiftingAppender will consider stale and consequently remove
- nested appenders which are closed or improperly started. This
- caters for the use case described in <a
+ <p><code>SiftingAppender</code> will consider stale and
+ consequently remove nested appenders which are closed or
+ improperly started. This caters for the use case described in <a
href="http://jira.qos.ch/browse/LBCLASSIC-316">LBCLASSIC-316</a>
by Guus Bloemsma.</p>
-----------------------------------------------------------------------
Summary of changes:
.../access/joran/action/ConfigurationAction.java | 10 ++------
.../classic/joran/action/ConfigurationAction.java | 10 ++------
.../core/joran/action/StatusListenerAction.java | 10 +++-----
.../core/status/OnConsoleStatusListener.java | 14 ++++++++++++
.../src/site/pages/manual/configuration.html | 23 +++++++++++--------
logback-site/src/site/pages/news.html | 17 +++++++++++---
6 files changed, 50 insertions(+), 34 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list