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
June 2010
- 5 participants
- 71 discussions

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-16-g44a4433
by git-noreply@pixie.qos.ch 21 Jun '10
by git-noreply@pixie.qos.ch 21 Jun '10
21 Jun '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, master has been updated
via 44a4433972f33a39600893903028a6860341c5ac (commit)
from cf03337b10f4d987ffa47d00a904e2565b8975a9 (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=44a4433972f33a3960089390…
http://github.com/ceki/logback/commit/44a4433972f33a39600893903028a6860341c…
commit 44a4433972f33a39600893903028a6860341c5ac
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon Jun 21 18:42:06 2010 +0200
- documenting buffer tracking funtionality in SMTPAppender
diff --git a/logback-classic/integration.xml b/logback-classic/integration.xml
index a8a5b3a..552e918 100644
--- a/logback-classic/integration.xml
+++ b/logback-classic/integration.xml
@@ -23,12 +23,12 @@
- <target name="testAll" depends="testWithoutGroovy">
+ <target name="testAll" depends="testWithoutGroovy" unless="maven.test.skip">
</target>
- <target name="testWithoutGroovy">
+ <target name="testWithoutGroovy" unless="maven.test.skip">
<junit printsummary="yes" fork="no" haltonfailure="yes">
<classpath refid="basicClasspath" />
<formatter type="plain" />
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 2d0ba69..f1605e0 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -282,8 +282,6 @@
<execution>
<id>ant-integration-test</id>
<phase>package</phase>
-
-
<configuration>
<tasks>
<property name="slf4j.version" value="${slf4j.version}"/>
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
index 0686228..b4e01b7 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
@@ -31,10 +31,6 @@ class ComponentDelegate extends ContextAwareBase {
this.component = component;
}
- Object getDeclaredOrigin() {
- return "ComponentDelegate"
- }
-
String getLabel() { "component" }
String getLabelFistLetterInUpperCase() { getLabel()[0].toUpperCase() + getLabel().substring(1) }
@@ -79,7 +75,6 @@ class ComponentDelegate extends ContextAwareBase {
void cascadeFields(ComponentDelegate subDelegate) {
for (String k: fieldsToCaccade) {
- println "cacsading ${k} with value ${this."${k}"}"
subDelegate.metaClass."${k}" = this."${k}"
}
}
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
index 5bda299..08d3c73 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
@@ -40,8 +40,7 @@ public class ConfigurationDelegate extends ContextAwareBase {
Object getDeclaredOrigin() {
- //println "ConfigurationDelegate"
- return "ConfigurationDelegate"
+ return this;
}
void scan(String scanPeriodStr = null) {
@@ -131,6 +130,11 @@ public class ConfigurationDelegate extends ContextAwareBase {
appender.start();
}
+
+ public void toto(String m) {
+ println "xxxxxxxxxxxxxxxxxxxx "+m;
+ }
+
private void copyContributions(AppenderDelegate appenderDelegate, Appender appender) {
if(appender instanceof ConfigurationContributor) {
ConfigurationContributor cc = (ConfigurationContributor) appender;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index 43e34e6..db5156d 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -58,6 +58,13 @@ import ch.qos.logback.core.util.OptionHelper;
*/
public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
+
+ // ~ 14 days
+ static final int MAX_DELAY_BETWEEN_STATUS_MESSAGES = 1228800 * CoreConstants.MILLIS_IN_ONE_SECOND;
+
+ long lastTrackerStatusPrint = 0;
+ int delayBetweenStatusMessages = 300 * CoreConstants.MILLIS_IN_ONE_SECOND;
+
protected Layout<E> subjectLayout;
protected Layout<E> layout;
@@ -159,11 +166,9 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
return;
}
-
- String key = discriminator.getDiscriminatingValue(eventObject);
-
- CyclicBuffer<E> cb = cbTracker.get(key, System.currentTimeMillis());
-
+ String key = discriminator.getDiscriminatingValue(eventObject);
+ long now = System.currentTimeMillis();
+ CyclicBuffer<E> cb = cbTracker.get(key, now);
subAppend(cb, eventObject);
try {
@@ -176,6 +181,15 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
addError("SMTPAppender's EventEvaluator threw an Exception-", ex);
}
}
+ cbTracker.clearStaleBuffers(now);
+ if (lastTrackerStatusPrint + delayBetweenStatusMessages < now) {
+ addInfo("SMTPAppender [" + name + "] is tracking [" + cbTracker.size() + "] buffers");
+ lastTrackerStatusPrint = now;
+ // quadruple 'delay' assuming less than max delay
+ if (delayBetweenStatusMessages < MAX_DELAY_BETWEEN_STATUS_MESSAGES) {
+ delayBetweenStatusMessages *= 4;
+ }
+ }
}
abstract protected void subAppend(CyclicBuffer<E> cb, E eventObject);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
index db82b74..4f1ab45 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
@@ -58,8 +58,14 @@ public interface CyclicBufferTracker<E> {
/**
* Clear (and detach) buffers which are stale.
- *
+ *
* @param now
*/
void clearStaleBuffers(long now);
+
+ /**
+ * The size of the internal map/list/collection holding the cyclic buffers.
+ * @return size of internal collection
+ */
+ int size();
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
index f71813c..c424b61 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
@@ -31,12 +31,18 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS;
int bufferCount = 0;
+ // 5 minutes
+ static final int DELAY_BETWEEN_CLEARING_STALE_BUFFERS = 300*CoreConstants.MILLIS_IN_ONE_SECOND ;
+
+
+
private Map<String, Entry> map = new HashMap<String, Entry>();
private Entry head; // least recently used entries are towards the head
private Entry tail; // most recently used entries are towards the tail
long lastCheck = 0;
+
public CyclicBufferTrackerImpl() {
head = new Entry(null, null, 0);
tail = head;
@@ -111,10 +117,11 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
public synchronized void clearStaleBuffers(long now) {
- if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+ if (lastCheck + DELAY_BETWEEN_CLEARING_STALE_BUFFERS > now) {
return;
}
lastCheck = now;
+
while (head.value != null && isEntryStale(head, now)) {
CyclicBuffer<E> cb = head.value;
cb.clear();
@@ -122,6 +129,10 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
}
}
+ public int size() {
+ return map.size();
+ }
+
final private boolean isEntryStale(Entry entry, long now) {
return ((entry.timestamp + THRESHOLD) < now);
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
index 53216d2..fc3f6a0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
@@ -35,6 +35,9 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
private static SimpleDateFormat SDF = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
+ static String SUBMIT = "submit";
+ static String CLEAR = "Clear";
+
protected abstract StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp);
protected abstract String getPageTitle(HttpServletRequest req, HttpServletResponse resp);
@@ -44,7 +47,6 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
- System.out.println("service called");
count = 0;
StatusManager sm = getStatusManager(req, resp);
@@ -58,6 +60,17 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
output.append("<body>\r\n");
output.append(getPageTitle(req, resp));
+
+ output.append("<form method=\"POST\">\r\n");
+ output.append("<input type=\"submit\" name=\""+SUBMIT+"\" value=\""+CLEAR+"\">");
+ output.append("</form>\r\n");
+
+
+ if(CLEAR.equalsIgnoreCase(req.getParameter(SUBMIT))) {
+ sm.clear();
+ sm.add(new InfoStatus("Cleared all status messages", this));
+ }
+
output.append("<table>");
StringBuilder buf = new StringBuilder();
if(sm != null) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
index fd56075..553104d 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
@@ -51,7 +51,7 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
TEntry te = getEntry(key);
if (te == null) {
CyclicBuffer<E> cb = new CyclicBuffer<E>(bufferSize);
- te = new TEntry<E>(key, cb, timestamp);
+ te = new TEntry<E>(key, cb, timestamp);
entryList.add(te);
return cb;
} else {
@@ -67,7 +67,7 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
}
public void clearStaleBuffers(long now) {
- if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+ if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
return;
}
lastCheck = now;
@@ -77,6 +77,11 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
}
}
+ public int size() {
+ return entryList.size();
+ }
+
+
// ==================================================================
private class TEntry<E> implements Comparable {
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
index 342de5d..01b1832 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
@@ -8,7 +8,6 @@
<configuration>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<Evaluator class="chapters.appenders.mail.CounterBasedEvaluator" />
- <BufferSize>1050</BufferSize>
<SMTPHost>${smtpHost}</SMTPHost>
<To>${to}</To>
<From>${from}</From>
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml
new file mode 100644
index 0000000..624684e
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml
@@ -0,0 +1,27 @@
+
+<configuration>
+ <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
+
+ <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost>
+ <to>EMAIL-DESTINATION</to>
+ <from>SENDER-EMAIL</from>
+
+
+ <discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
+ <key>req.remoteHost</key>
+ <defaultValue>default</defaultValue>
+ </discriminator>
+
+ <subject>${HOSTNAME} -- %X{req.remoteHost} %msg"</subject>
+ <layout class="ch.qos.logback.classic.html.HTMLLayout">
+ <pattern>%date%level%thread%X{req.remoteHost}%X{req.requestURL}%X{req.queryString}%logger%msg</pattern>
+ </layout>
+ </appender>
+
+ <root>
+ <level level="DEBUG"/>
+ <appender-ref ref="EMAIL" />
+ </root>
+</configuration>
+
+
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
index c1c7127..4095d5b 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
@@ -7,7 +7,6 @@
<!-- you specify add as many markers as you want -->
<marker>ANOTHER_MARKER</marker>
</evaluator>
- <BufferSize>1050</BufferSize>
<SMTPHost>${smtpHost}</SMTPHost>
<To>${to}</To>
<From>${from}</From>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 232775b..4a9b92c 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -2141,10 +2141,11 @@ Context ctx = new InitialContext(env);</pre>
<p>The <a
href="../xref/ch/qos/logback/classic/net/SMTPAppender.html"><code>SMTPAppender</code></a>
- accumulates logging events in a fixed-size buffer and sends them in
- an email after a user-specified event occurs. By default, the
- email transmission is triggered by a logging event of level ERROR
- or higher.
+ accumulates logging events in one or more fixed-size buffers and
+ sends the contents of the appropriate bugger in an email after a
+ user-specified event occurs. By default, the email transmission is
+ triggered by a logging event of level ERROR or higher. Moreover, by
+ default, a single buffer is used for all events.
</p>
<p>The various properties for <code>SMTPAppender</code> are
@@ -2210,20 +2211,30 @@ Context ctx = new InitialContext(env);</pre>
</td>
</tr>
<tr class="alt">
- <td><b><span class="option">BufferSize</span></b></td>
- <td><code>int</code></td>
+
+
+ <td><b><span class="option">Discriminator</span></b></td>
+ <td><code><a href="../xref/ch/qos/logback/core/sift/Discriminator.html">Discriminator</a></code></td>
<td>
- The <span class="option">BufferSize</span> option takes a
- positive integer representing the maximum number of logging
- events to collect in a cyclic buffer. When the <span
- class="option">BufferSize</span> is reached, oldest events
- are deleted as new events are added to the buffer. The
- default size of the cyclic buffer is 512.
+ <p>With the help of a <span
+ class="option">Discriminator</span>,
+ <code>SMTPAppender</code> can scatter incoming events into
+ different buffers according to the value returned by the
+ discriminator. The default discriminator always returns the
+ same value so that the same buffer is used for all events.
+ </p>
+
+ <p>By specifiying a discriminator other than the default
+ one, it would be possible to receive email messages
+ containing a events pertaining to a particular user, user
+ session or client IP address.
+ </p>
</td>
</tr>
<tr >
<td><b><span class="option">Evaluator</span></b></td>
- <td><code>String</code></td>
+ <td><code><a
+ href="../xref/ch/qos/logback/classic/boolex/IEvaluator.html">IEvaluator</a></code></td>
<td>
<p>This option is declared by creating a new
<code><EventEvaluator/></code> element. The name of the
@@ -2294,14 +2305,12 @@ Context ctx = new InitialContext(env);</pre>
</table>
- <p>The SMTPAppender keeps only the last <span
- class="option">BufferSize</span> logging events in its cyclic
- buffer, throwing away older events when its buffer becomes full.
- Thus, the number of logging events delivered in any e-mail sent by
- <code>SMTPAppender</code> is upper-bounded by <span
- class="option">BufferSize</span>. This keeps memory requirements
- bounded while still delivering a reasonable amount of application
- context.
+ <p>The <code>SMTPAppender</code> keeps only the last 256 logging
+ events in its cyclic buffer, throwing away older events when its
+ buffer becomes full. Thus, the number of logging events delivered
+ in any e-mail sent by <code>SMTPAppender</code> is upper-bounded
+ by 256. This keeps memory requirements bounded while still
+ delivering a reasonable amount of application context.
</p>
<p>The <code>SMTPAppender</code> relies on the JavaMail API. It
@@ -2316,7 +2325,6 @@ Context ctx = new InitialContext(env);</pre>
the following examples.
</p>
-
<p>A sample application, <a
href="../xref/chapters/appenders/mail/EMail.html"><code>chapters.appenders.mail.EMail</code></a>
generates a number of log messages messages followed by a single
@@ -2359,10 +2367,10 @@ Context ctx = new InitialContext(env);</pre>
configuration file, execute the following command:
</p>
-<div class="source"><pre>java chapters.appenders.mail.EMail 300 src/main/java/chapters/appenders/mail/mail1.xml</pre></div>
+<div class="source"><pre>java chapters.appenders.mail.EMail 100 src/main/java/chapters/appenders/mail/mail1.xml</pre></div>
<p>The recipient you specified should receive an email message
- containing 300 logging events formatted by
+ containing 100 logging events formatted by
<code>PatternLayout</code> The figure below is the resulting email
message as shown by Mozilla Thunderbird.
</p>
@@ -2401,12 +2409,12 @@ Context ctx = new InitialContext(env);</pre>
for further details.
</p>
- <p>Given that the default size of the cyclic buffer is 512, the
- recipient should see an email message containing 512 events
- conveniently formatted in an HTML table. Note that this run of the
- <code>chapters.appenders.mail.Email</code> application generated 10'000
- events of which only the last 512 were included in the outgoing
- email.
+ <p>Given that the size of the cyclic buffer is 256, the recipient
+ should see an email message containing 256 events conveniently
+ formatted in an HTML table. Note that this run of the
+ <code>chapters.appenders.mail.Email</code> application generated
+ 10'000 events of which only the last 256 were included in the
+ outgoing email.
</p>
<p><img src="images/chapters/appenders/smtpAppender2.jpg" alt="2nd email"/></p>
@@ -2495,8 +2503,8 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
<p>Setting the <span class="option">Evaluator</span> option of
<code>SMTPAppender</code> instructs it to use a custom evaluator.
The next configuration file attaches a <code>SMTPAppender</code>
- to the root logger. This appender has a buffer size of 2048 and
- uses a <code>CounterBasedEvaluator</code> instance as its event
+ to the root logger. This appender uses a
+ <code>CounterBasedEvaluator</code> instance as its event
evaluator.
</p>
@@ -2506,7 +2514,6 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
<pre id="mail3" class="prettyprint source"><configuration>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<b><Evaluator class="chapters.appenders.mail.CounterBasedEvaluator" /></b>
- <BufferSize>1050</BufferSize>
<SMTPHost>${smtpHost}</SMTPHost>
<To>${to}</To>
<From>${from}</From>
@@ -2560,7 +2567,6 @@ logger.error(<b>notifyAdminMarker</b>,
<!-- you specify add as many markers as you want -->
<marker>TRANSACTION_FAILURE</marker>
</evaluator></b>
- <BufferSize>1050</BufferSize>
<SMTPHost>${smtpHost}</SMTPHost>
<To>${to}</To>
<From>${from}</From>
@@ -2658,6 +2664,61 @@ logger.error(<b>notifyAdminMarker</b>,
</configuration></pre>
+ <h3><a name="smtpDiscriminator"
+ href="#smtpDiscriminator">SMTPAppender with
+ MDCDiscriminator</a></h3>
+
+ <p>As mentioned earlier, by specifiying a discriminator other than
+ the default one, SMTPAppender will generate email messages
+ containing events pertaining to a particular user, user session or
+ client IP address, depending on the discriminator.
+ </p>
+
+ <p>The next example uses <a
+ href="../xref/ch/qos/logback/classic/sift/MDCBasedDiscriminator.html">MDCBasedDsicriminator</a>
+ focused on the MDC key named "req.remoteHost" which is assumed to
+ contain the IP address of the remote host accessing a fictitious
+ application. In a web-application, you could use <a
+ href="mdc.html#mis">MDCInsertingServletFilter</a> to populate MDC
+ values.
+ </p>
+
+ <p class="example">Example: <code>SMTPAppender</code> with
+ MDCBasedDsicriminator
+ (logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml)</p>
+
+ <span class="asGroovy" onclick="return asGroovy('mailWithMDCBasedDiscriminator');">View as .grovvy</span>
+ <pre id="mailWithMDCBasedDiscriminator" class="prettyprint source"><configuration>
+ <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
+ <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost>
+ <to>EMAIL-DESTINATION</to>
+ <from>SENDER-EMAIL</from>
+
+ <b><discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator"></b>
+ <b><key>req.remoteHost</key></b>
+ <b><defaultValue>default</defaultValue></b>
+ <b></discriminator></b>
+
+ <subject>${HOSTNAME} -- %X{req.remoteHost} %msg"</subject>
+ <layout class="ch.qos.logback.classic.html.HTMLLayout">
+ <pattern>%date%level%thread%X{req.remoteHost}%X{req.requestURL}%logger%msg</pattern>
+ </layout>
+ </appender>
+
+ <root>
+ <level level="DEBUG"/>
+ <appender-ref ref="EMAIL" />
+ </root>
+</configuration></pre>
+
+ <p>Thus, each outgoing emails generated by
+ <code>SMTPAppender</code> will belong to a <em>unique</em> remote
+ host, greatly facilitating problem diagnosis.
+ </p>
+
+ <!-- =========================================================== -->
+ <!-- =========================================================== -->
+
<h3>
<a name="DBAppender" href="#DBAppender">DBAppender</a>
diff --git a/logback-site/src/site/pages/manual/groovy.html b/logback-site/src/site/pages/manual/groovy.html
index 81be827..46e7f1d 100644
--- a/logback-site/src/site/pages/manual/groovy.html
+++ b/logback-site/src/site/pages/manual/groovy.html
@@ -70,8 +70,8 @@
programs. And since groovy is a super-set of Java, whatever
configuration actions you can perform in Java, you can do the same
within a <em>logback.groovy</em> file. However, since configuring
- logback progammatically using Java syntax can be very cumbersome,
- we added a few logback-specific extensions to make your life
+ logback progammatically using Java syntax can be cumbersome, we
+ added a few logback-specific extensions to make your life
easier. We try hard to limit the number of logback-specific
syntactic extensions to an absolute minimum. If you are already
familiar with groovy, you should be able to read, understand and
@@ -81,6 +81,11 @@
<em>logback.xml</em>.
</p>
+ <p>Given that <em>logback.groovy</em> files are groovy programs
+ with minimal logback-specific extensins, <em>all</em> the usual
+ groovy constructs such as class imports, variable definitions,
+ if-else statements are avaiable in <em>logback.groovy</em> files.</p>
+
<p><em>Logback.groovy</em> syntax consists of half a dozen methods
described next in the reverse order of their customary
appearance. Strictly speaking, the order of invocation of these
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index d9e4272..446a827 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -29,7 +29,7 @@
<hr width="80%" align="center" />
- <h3>June 2xth, 2010 - Release of version 0.9.22</h3>
+ <h3>June 21st, 2010 - Release of version 0.9.22</h3>
<p>Logback now supports <a href="manual/groovy.html">configuration
files written in Groovy</a> which are more convenient than
@@ -39,6 +39,13 @@
migrate your logback.xml files to logback.groovy</a>.
</p>
+ <p>Inspired by the functionality offered by
+ <code>SiftingAppender</code>, <code>SMTPApppender</code> now can
+ <a href="manual/appenders.html#smtpDiscriminator">track multiple
+ buffers according to selection informaiton returned by a
+ discriminator</a>.
+ </p>
+
<p>Fixed synchronization issue in <code>ConsoleAppender</code> as
reported in <a
href="http://jira.qos.ch/browse/LBCORE-158">LBCORE-158</a> by
-----------------------------------------------------------------------
Summary of changes:
logback-classic/integration.xml | 4 +-
logback-classic/pom.xml | 2 -
.../classic/gaffer/ComponentDelegate.groovy | 5 -
.../classic/gaffer/ConfigurationDelegate.groovy | 8 +-
.../ch/qos/logback/core/net/SMTPAppenderBase.java | 24 +++-
.../qos/logback/core/spi/CyclicBufferTracker.java | 8 +-
.../logback/core/spi/CyclicBufferTrackerImpl.java | 13 ++-
.../core/status/ViewStatusMessagesServletBase.java | 15 ++-
.../core/spi/CyclicBufferTracker_TImpl.java | 9 +-
.../main/java/chapters/appenders/mail/mail3.xml | 1 -
.../mail/mailWithMDCBasedDiscriminator.xml | 27 ++++
.../chapters/appenders/mail/mailWithMarker.xml | 1 -
logback-site/src/site/pages/manual/appenders.html | 129 ++++++++++++++-----
logback-site/src/site/pages/manual/groovy.html | 9 +-
logback-site/src/site/pages/news.html | 9 ++-
15 files changed, 204 insertions(+), 60 deletions(-)
create mode 100644 logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml
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_0.9.21-15-gcf03337
by git-noreply@pixie.qos.ch 17 Jun '10
by git-noreply@pixie.qos.ch 17 Jun '10
17 Jun '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, master has been updated
via cf03337b10f4d987ffa47d00a904e2565b8975a9 (commit)
from 263b38aad03194fc0ec2c1b91ca8c99c885d1404 (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=cf03337b10f4d987ffa47d00…
http://github.com/ceki/logback/commit/cf03337b10f4d987ffa47d00a904e2565b897…
commit cf03337b10f4d987ffa47d00a904e2565b8975a9
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Jun 17 23:38:58 2010 +0200
- ch.logback.core.pattern.Converter write() method changed the first
parameter from StringBuffer to StringBuilder. Since converters do not
override this method, the change should not effect users with custom
converters.
- Added support for logback.groovy reload in ReconfigureOnChangeFilter
diff --git a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
index e876b75..51b6fa4 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
@@ -92,7 +92,7 @@ public class HTMLLayout extends HTMLLayoutBase<AccessEvent> {
buf.append("<td class=\"");
buf.append(computeConverterName(c));
buf.append("\">");
- buf.append(c.convert(event));
+ c.write(buf, event);
buf.append("</td>");
buf.append(LINE_SEPARATOR);
}
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
index ffd99cb..162df73 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/GafferConfigurator.groovy
@@ -36,6 +36,11 @@ class GafferConfigurator {
run(url.text);
}
+ void run(File file) {
+ informContextOfURLUsedForConfiguration(file.toURI().toURL());
+ run(file.text);
+ }
+
void run(String dslText) {
Binding binding = new Binding();
binding.setProperty("hostname", ContextUtil.getLocalHostName());
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
index 9152f46..17e8b79 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
@@ -112,7 +112,7 @@ public class HTMLLayout extends HTMLLayoutBase<ILoggingEvent> {
buf.append("<td class=\"");
buf.append(computeConverterName(c));
buf.append("\">");
- buf.append(c.convert(event));
+ c.write(buf, event);
buf.append("</td>");
buf.append(LINE_SEPARATOR);
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
index cd04f93..8aee404 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/turbo/ReconfigureOnChangeFilter.java
@@ -17,6 +17,10 @@ import java.io.File;
import java.net.URL;
import java.net.URLDecoder;
+import ch.qos.logback.classic.gaffer.GafferConfigurator;
+import ch.qos.logback.classic.util.EnvUtil;
+import ch.qos.logback.core.status.ErrorStatus;
+import ch.qos.logback.core.status.StatusManager;
import org.slf4j.Marker;
import ch.qos.logback.classic.Level;
@@ -30,9 +34,8 @@ import ch.qos.logback.core.status.InfoStatus;
/**
* Reconfigure a LoggerContext when the configuration file changes.
- *
+ *
* @author Ceki Gulcu
- *
*/
public class ReconfigureOnChangeFilter extends TurboFilter {
@@ -55,14 +58,14 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
@Override
public void start() {
URL url = (URL) context
- .getObject(CoreConstants.URL_OF_LAST_CONFIGURATION_VIA_JORAN);
+ .getObject(CoreConstants.URL_OF_LAST_CONFIGURATION_VIA_JORAN);
if (url != null) {
fileToScan = convertToFile(url);
if (fileToScan != null) {
synchronized (lock) {
long inSeconds = refreshPeriod / 1000;
addInfo("Will scan for changes in file [" + fileToScan + "] every "
- + inSeconds + " seconds. ");
+ + inSeconds + " seconds. ");
lastModified = fileToScan.lastModified();
updateNextCheck(System.currentTimeMillis());
}
@@ -95,7 +98,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
@Override
public FilterReply decide(Marker marker, Logger logger, Level level,
- String format, Object[] params, Throwable t) {
+ String format, Object[] params, Throwable t) {
if (!isStarted()) {
return FilterReply.NEUTRAL;
}
@@ -119,6 +122,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
// by detaching reconfiguration to a new thread, we release the various
// locks held by the current thread, in particular, the AppenderAttachable
// reader lock.
+
private void detachReconfigurationToNewThread() {
// Even though this method resets the loggerContext, which clears the
// list of turbo filters including this instance, it is still possible
@@ -135,6 +139,7 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
}
// This method is synchronized to prevent near-simultaneous re-configurations
+
protected boolean changeDetected() {
long now = System.currentTimeMillis();
if (now >= nextCheck) {
@@ -162,17 +167,32 @@ public class ReconfigureOnChangeFilter extends TurboFilter {
class ReconfiguringThread extends Thread {
public void run() {
- JoranConfigurator jc = new JoranConfigurator();
- jc.setContext(context);
LoggerContext lc = (LoggerContext) context;
- lc.reset();
- try {
- jc.doConfigure(fileToScan);
- } catch (JoranException e) {
- addError("Failure during reconfiguration", e);
+
+ if (fileToScan.toString().endsWith("groovy")) {
+ if (EnvUtil.isGroovyAvailable()) {
+ lc.reset();
+ GafferConfigurator gafferConfigurator = new GafferConfigurator(lc);
+ gafferConfigurator.run(fileToScan);
+ lc.getStatusManager().add(
+ new InfoStatus("done resetting the logging context", this));
+ } else {
+ StatusManager sm = context.getStatusManager();
+ sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.",
+ context));
+ }
+ } else if (fileToScan.toString().endsWith("xml")) {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(context);
+ lc.reset();
+ try {
+ jc.doConfigure(fileToScan);
+ lc.getStatusManager().add(
+ new InfoStatus("done resetting the logging context", this));
+ } catch (JoranException e) {
+ addError("Failure during reconfiguration", e);
+ }
}
- lc.getStatusManager().add(
- new InfoStatus("done resetting the logging context", this));
}
}
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
index ccd4ee3..73d92dc 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/EnvUtil.java
@@ -19,7 +19,7 @@ package ch.qos.logback.classic.util;
public class EnvUtil {
- static boolean isGroovyAvailable() {
+ static public boolean isGroovyAvailable() {
ClassLoader classLoader = EnvUtil.class.getClassLoader();
try {
Class bindingClass = classLoader.loadClass("groovy.lang.Binding");
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
index e9d6a07..8c18e06 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
@@ -71,7 +71,6 @@ public class JaninoEventEvaluatorTest {
jee.start();
ILoggingEvent event = makeLoggingEvent(null);
- // System.out.println(event);
assertTrue(jee.evaluate(event));
}
@@ -81,7 +80,6 @@ public class JaninoEventEvaluatorTest {
jee.start();
ILoggingEvent event = makeLoggingEvent(null);
- // System.out.println(event);
assertTrue(jee.evaluate(event));
}
@@ -262,4 +260,13 @@ public class JaninoEventEvaluatorTest {
assertTrue(jee.evaluate(event));
}
+
+ @Test
+ public void nullMDC() throws EvaluationException {
+ jee.setExpression("mdc == null");
+ jee.start();
+
+ LoggingEvent event = makeLoggingEvent(null);
+ assertTrue(jee.evaluate(event));
+ }
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
index 5611786..f39f1f3 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
@@ -71,7 +71,7 @@ public class ConverterTest {
public void testLineOfCaller() {
{
DynamicConverter<ILoggingEvent> converter = new LineOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
// the number below should be the line number of the previous line
assertEquals("75", buf.toString());
@@ -82,14 +82,14 @@ public class ConverterTest {
public void testLevel() {
{
DynamicConverter<ILoggingEvent> converter = new LevelConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("INFO", buf.toString());
}
{
DynamicConverter<ILoggingEvent> converter = new LevelConverter();
converter.setFormattingInfo(new FormatInfo(1, 1, true, false));
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("I", buf.toString());
}
@@ -98,7 +98,7 @@ public class ConverterTest {
@Test
public void testThread() {
DynamicConverter<ILoggingEvent> converter = new ThreadConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
assertTrue(buf.toString().matches(regex));
@@ -107,7 +107,7 @@ public class ConverterTest {
@Test
public void testMessage() {
DynamicConverter<ILoggingEvent> converter = new MessageConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("Some message", buf.toString());
}
@@ -115,7 +115,7 @@ public class ConverterTest {
@Test
public void testLineSeparator() {
DynamicConverter<ILoggingEvent> converter = new LineSeparatorConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(CoreConstants.LINE_SEPARATOR, buf.toString());
}
@@ -124,7 +124,7 @@ public class ConverterTest {
public void testException() {
{
DynamicConverter<ILoggingEvent> converter = new ThrowableProxyConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
}
@@ -132,7 +132,7 @@ public class ConverterTest {
DynamicConverter<ILoggingEvent> converter = new ThrowableProxyConverter();
this.optionList.add("3");
converter.setOptionList(this.optionList);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
}
}
@@ -141,7 +141,7 @@ public class ConverterTest {
public void testLogger() {
{
ClassicConverter converter = new LoggerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(this.getClass().getName(), buf.toString());
}
@@ -151,7 +151,7 @@ public class ConverterTest {
this.optionList.add("20");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("c.q.l.c.p.ConverterTest", buf.toString());
}
@@ -162,7 +162,7 @@ public class ConverterTest {
this.optionList.add("0");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("ConverterTest", buf.toString());
}
@@ -174,7 +174,7 @@ public class ConverterTest {
this.optionList.add("5");
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
char c = 'a';
int extraParts = 3;
@@ -203,7 +203,7 @@ public class ConverterTest {
@Test
public void testClass() {
DynamicConverter<ILoggingEvent> converter = new ClassOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals(this.getClass().getName(), buf.toString());
}
@@ -211,7 +211,7 @@ public class ConverterTest {
@Test
public void testMethodOfCaller() {
DynamicConverter<ILoggingEvent> converter = new MethodOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("testMethodOfCaller", buf.toString());
}
@@ -219,7 +219,7 @@ public class ConverterTest {
@Test
public void testFileOfCaller() {
DynamicConverter<ILoggingEvent> converter = new FileOfCallerConverter();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertEquals("ConverterTest.java", buf.toString());
}
@@ -230,7 +230,7 @@ public class ConverterTest {
DynamicConverter<ILoggingEvent> converter = new CallerDataConverter();
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
if (buf.length() < 10) {
fail("buf is too short");
@@ -244,7 +244,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("XXX"));
converter.write(buf, event);
@@ -262,7 +262,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("YYY"));
converter.write(buf, event);
@@ -279,7 +279,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
LoggingEvent event = makeLoggingEvent(null);
event.setMarker(MarkerFactory.getMarker("YYY"));
converter.write(buf, event);
@@ -297,7 +297,7 @@ public class ConverterTest {
converter.setOptionList(this.optionList);
converter.start();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, le);
if (buf.length() < 10) {
fail("buf is too short");
@@ -310,8 +310,8 @@ public class ConverterTest {
@Test
public void testRelativeTime() throws Exception {
DynamicConverter<ILoggingEvent> converter = new RelativeTimeConverter();
- StringBuffer buf0 = new StringBuffer();
- StringBuffer buf1 = new StringBuffer();
+ StringBuilder buf0 = new StringBuilder();
+ StringBuilder buf1 = new StringBuilder();
ILoggingEvent e0 = makeLoggingEvent(null);
ILoggingEvent e1 = makeLoggingEvent(null);
converter.write(buf0, e0);
@@ -329,7 +329,7 @@ public class ConverterTest {
ILoggingEvent event = makeLoggingEvent(null);
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
converter.write(buf, event);
String expected = "<"
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
index 667d409..07e352e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/CompositeConverter.java
@@ -15,12 +15,12 @@ package ch.qos.logback.core.pattern;
public class CompositeConverter<E> extends FormattingConverter<E> {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Converter<E> childConverter;
public String convert(E event) {
if (buf.capacity() > MAX_CAPACITY) {
- buf = new StringBuffer(INITIAL_BUF_SIZE);
+ buf = new StringBuilder(INITIAL_BUF_SIZE);
} else {
buf.setLength(0);
}
@@ -36,7 +36,7 @@ public class CompositeConverter<E> extends FormattingConverter<E> {
}
public String toString() {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
buf.append("CompositeConverter<");
if(formattingInfo != null)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
index 5a140d8..7a9c71e 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/Converter.java
@@ -38,7 +38,7 @@ abstract public class Converter<E> {
* @param buf The input buffer where data is appended
* @param event The event from where data is extracted
*/
- public void write(StringBuffer buf, E event) {
+ public void write(StringBuilder buf, E event) {
buf.append(convert(event));
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
index b228d0d..09e2869 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/FormattingConverter.java
@@ -32,7 +32,8 @@ abstract public class FormattingConverter<E> extends Converter<E> {
this.formattingInfo = formattingInfo;
}
- final public void write(StringBuffer buf, E event) {
+ @Override
+ final public void write(StringBuilder buf, E event) {
String s = convert(event);
if(formattingInfo == null) {
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 6a76153..d507887 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
@@ -112,7 +112,7 @@ abstract public class PatternLayoutBase<E> extends LayoutBase<E> {
}
protected String writeLoopOnConverters(E event) {
- StringBuffer buf = new StringBuffer(128);
+ StringBuilder buf = new StringBuilder(128);
Converter<E> c = head;
while (c != null) {
c.write(buf, event);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
index b7b444e..76f9472 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/pattern/SpacePadder.java
@@ -20,7 +20,7 @@ public class SpacePadder {
" ", // 16 spaces
" " }; // 32 spaces
- final static public void leftPad(StringBuffer buf, String s, int desiredLength) {
+ final static public void leftPad(StringBuilder buf, String s, int desiredLength) {
int actualLen = 0;
if (s != null) {
actualLen = s.length();
@@ -33,7 +33,7 @@ public class SpacePadder {
}
}
- final static public void rightPad(StringBuffer buf, String s, int desiredLength) {
+ final static public void rightPad(StringBuilder buf, String s, int desiredLength) {
int actualLen = 0;
if (s != null) {
actualLen = s.length();
@@ -49,7 +49,7 @@ public class SpacePadder {
/**
* Fast space padding method.
*/
- final static public void spacePad(StringBuffer sbuf, int length) {
+ final static public void spacePad(StringBuilder sbuf, int length) {
while (length >= 32) {
sbuf.append(SPACES[5]);
length -= 32;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
index 97866a6..de44af1 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/SpacePadderTest.java
@@ -42,13 +42,13 @@ public class SpacePadderTest {
@Test
public void smoke() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "a";
SpacePadder.leftPad(buf, s, 4);
assertEquals(" a", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "a";
SpacePadder.rightPad(buf, s, 4);
assertEquals("a ", buf.toString());
@@ -59,12 +59,12 @@ public class SpacePadderTest {
public void nullString() {
String s = null;
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
SpacePadder.leftPad(buf, s, 2);
assertEquals(" ", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
SpacePadder.rightPad(buf, s, 2);
assertEquals(" ", buf.toString());
}
@@ -73,14 +73,14 @@ public class SpacePadderTest {
@Test
public void longString() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.leftPad(buf, s, 2);
assertEquals(s, buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.rightPad(buf, s, 2);
assertEquals(s, buf.toString());
@@ -90,13 +90,13 @@ public class SpacePadderTest {
@Test
public void lengthyPad() {
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.leftPad(buf, s, 33);
assertEquals(" abc", buf.toString());
}
{
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
String s = "abc";
SpacePadder.rightPad(buf, s, 33);
assertEquals("abc ", buf.toString());
diff --git a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
index 76848bc..8c64c59 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/CompilerTest.java
@@ -43,7 +43,7 @@ public class CompilerTest {
String write(final Converter<Object> head, Object event) {
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Converter<Object> c = head;
while (c != null) {
c.write(buf, event);
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index 5e49139..6340456 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -297,7 +297,9 @@ public class SampleFilter extends Filter>ILoggingEvent> {
TRACE, DEBUG, INFO, WARN and ERROR are also exported into the
scope of the expression. Thus, "event.level == DEBUG" is a valid
groovy expression which will return <code>true</code> only if the
- current logging event's level is equal to DEBUG.
+ current logging event's level is identical to DEBUG. For other
+ comparison operators, the level field should be converter to
+ integer with the <code>toInt()</code> operator.
</p>
<p>Here is a more complete example.</p>
@@ -309,7 +311,7 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<b><filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
<expression>
- e.level>=WARN
+ e.level.toInt() >= WARN.toInt()
&amp;&amp; <!-- Stands for && in XML -->
!(e.mdc?.get("req.userAgent") ~= /Googlebot|msnbot|Yahoo/ )
</expression>
@@ -471,7 +473,9 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<td><code>Map</code></td>
<td>A map containing all the MDC values at the time of the
creation of the logging event. A value can be accessed by
- using the following expression: <em>mdc.get("myKey")</em>.
+ using the following expression: <em>mdc.get("myKey")</em>. The
+ 'mdc' variable can be null and this possibility should be
+ checked for in evaluator expressions.
<p>The <code>java.util.Map</code> type is non-parametirezied
because Janino does not support generics. It follows that the
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/access/html/HTMLLayout.java | 2 +-
.../classic/gaffer/GafferConfigurator.groovy | 5 ++
.../ch/qos/logback/classic/html/HTMLLayout.java | 2 +-
.../classic/turbo/ReconfigureOnChangeFilter.java | 48 ++++++++++++++------
.../java/ch/qos/logback/classic/util/EnvUtil.java | 2 +-
.../classic/boolex/JaninoEventEvaluatorTest.java | 11 ++++-
.../qos/logback/classic/pattern/ConverterTest.java | 46 +++++++++---------
.../logback/core/pattern/CompositeConverter.java | 6 +-
.../ch/qos/logback/core/pattern/Converter.java | 2 +-
.../logback/core/pattern/FormattingConverter.java | 3 +-
.../logback/core/pattern/PatternLayoutBase.java | 2 +-
.../ch/qos/logback/core/pattern/SpacePadder.java | 6 +-
.../qos/logback/core/pattern/SpacePadderTest.java | 16 +++---
.../logback/core/pattern/parser/CompilerTest.java | 2 +-
logback-site/src/site/pages/manual/filters.html | 10 +++-
15 files changed, 100 insertions(+), 63 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_0.9.21-14-g263b38a
by git-noreply@pixie.qos.ch 17 Jun '10
by git-noreply@pixie.qos.ch 17 Jun '10
17 Jun '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, master has been updated
via 263b38aad03194fc0ec2c1b91ca8c99c885d1404 (commit)
via 2d15361dfeeabfb8155ab94fab624e73c07d4ca1 (commit)
via 4d88ab7333f6869bafb81cad50235c0668120bf7 (commit)
via a4257048960bc721dc1c0be167e22e7f0466ea79 (commit)
via f18d4917d502f5d8703f83fc252928c4403cfd92 (commit)
from a052f15d09636698c96fcdb753da3270f5c01b11 (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=263b38aad03194fc0ec2c1b9…
http://github.com/ceki/logback/commit/263b38aad03194fc0ec2c1b91ca8c99c885d1…
commit 263b38aad03194fc0ec2c1b91ca8c99c885d1404
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Jun 17 11:31:55 2010 +0200
- Fixed LBCORE-158
- added parent injection support in gaffer
- updated news.html
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
index 471c148..0686228 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
@@ -61,14 +61,9 @@ class ComponentDelegate extends ContextAwareBase {
if (closure) {
ComponentDelegate subDelegate = new ComponentDelegate(subComponent)
- cascadeFields(subDelegate);
- for (String k: fieldsToCaccade) {
- //println "caccading ${k} with value ${this."${k}"}"
- //subDelegate.metaClass."${k}" = this."${k}"
- }
-
-
+ cascadeFields(subDelegate)
subDelegate.context = context
+ injectParent(subComponent)
closure.delegate = subDelegate
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
@@ -89,6 +84,12 @@ class ComponentDelegate extends ContextAwareBase {
}
}
+ void injectParent(Object subComponent) {
+ if(subComponent.hasProperty("parent")) {
+ subComponent.parent = component;
+ }
+ }
+
void propertyMissing(String name, def value) {
NestingType nestingType = PropertyUtil.nestingType(component, name);
if (nestingType == NestingType.NA) {
diff --git a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
index 7cc9a35..b923433 100644
--- a/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
+++ b/logback-classic/src/test/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegateTest.groovy
@@ -17,6 +17,10 @@ import ch.qos.logback.core.encoder.LayoutWrappingEncoder
import ch.qos.logback.classic.PatternLayout
import ch.qos.logback.core.util.StatusPrinter
import ch.qos.logback.classic.net.SMTPAppender
+import ch.qos.logback.core.rolling.RollingFileAppender
+import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder
+import ch.qos.logback.core.util.CoreTestConstants
/**
* @author Ceki Gücü
@@ -28,6 +32,8 @@ class ConfigurationDelegateTest {
StatusChecker statusChecker = new StatusChecker(context)
int diff = RandomUtil.getPositiveInt();
+ String randomOutputDir = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "/";
+
@Before
void setUp() {
context.name = "ConfigurationDelegateTest"
@@ -148,8 +154,8 @@ class ConfigurationDelegateTest {
@Test
void appenderWithEncoder() {
configurationDelegate.appender("C", ConsoleAppender) {
- encoder (LayoutWrappingEncoder) {
- layout (PatternLayout) {
+ encoder(LayoutWrappingEncoder) {
+ layout(PatternLayout) {
pattern = "%m%n"
}
}
@@ -160,29 +166,50 @@ class ConfigurationDelegateTest {
ConsoleAppender ca = back
assertNotNull(ca.encoder)
assertNotNull(ca.encoder.layout)
- PatternLayout layout = ca.encoder.layout
+ PatternLayout layout = ca.encoder.layout
assertEquals("%m%n", layout.pattern)
}
- @Test
+ @Test
void appenderSMTP() {
configurationDelegate.appender("SMTP", SMTPAppender) {
to = "a"
to = "b"
- layout (PatternLayout) {
- pattern = "%m%n"
+ layout(PatternLayout) {
+ pattern = "%m%n"
}
}
- StatusPrinter.print context
+ //StatusPrinter.print context
Appender back = configurationDelegate.appenderList.find {it.name = "SMTP"}
assertNotNull(back)
assertEquals("SMTP", back.name)
SMTPAppender sa = back
- PatternLayout layout = sa.layout
+ PatternLayout layout = sa.layout
assertEquals("%m%n", layout.pattern)
assertEquals(["a", "b"], sa.toList.sort());
+ }
+
+ // test parent injection
+
+ @Test
+ void appenderRolling() {
+
+ String logFile = randomOutputDir+"log.txt";
+ configurationDelegate.appender("ROLLING", RollingFileAppender) {
+ file = logFile
+ rollingPolicy(TimeBasedRollingPolicy) {
+ fileNamePattern = randomOutputDir+"log.%d{yyyy-MM}.log.zip"
+ }
+ encoder(PatternLayoutEncoder) {
+ pattern = '%msg%n'
+ }
+ }
+ // StatusPrinter.print context
+ RollingFileAppender back = configurationDelegate.appenderList.find {it.name = "ROLLING"}
+ assertNotNull(back)
+ assertEquals(logFile, back.rollingPolicy.getParentsRawFileProperty())
}
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
index 41ccfc2..9070aca 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
@@ -22,6 +22,7 @@ import java.io.OutputStream;
* @author Ceki Gülcü
* @author Tom SH Liu
* @author Ruediger Dohna
+ * @author David Roussel
*/
public enum ConsoleTarget {
diff --git a/logback-site/src/site/pages/faq.html b/logback-site/src/site/pages/faq.html
index 12f8427..78477d4 100644
--- a/logback-site/src/site/pages/faq.html
+++ b/logback-site/src/site/pages/faq.html
@@ -50,10 +50,10 @@
</li>
<li>
- <a href="#configFileLocation">Where should the configuration files,
- <em>logback-test.xml</em> or <em>logback.xml</em>, be located
- on the classpath?</a>
- </li>
+ <a href="#configFileLocation">Where should the configuration
+ files such as <em>logback.groovy</em>,
+ <em>logback-test.xml</em> or <em>logback.xml</em> be located
+ on the classpath?</a> </li>
<li>
<a href="#sharedConfiguration">Is it possible for multiple JEE
@@ -151,20 +151,25 @@
<!-- ========================================================= -->
<dt>
- <a name="configFileLocation" href="#configFileLocation">Where
- should the configuration files, <em>logback-test.xml</em> or
- <em>logback.xml</em>, be located on the classpath?</a>
- </dt>
+
+ <a name="configFileLocation"
+ href="#configFileLocation">Where should the configuration
+ files such as <em>logback.groovy</em>,
+ <em>logback-test.xml</em> or <em>logback.xml</em> be located
+ on the classpath?</a>
+ </dt>
+
<dd>
- <p>Configuration files such as <em>logback-test.xml</em> or
- <em>logback.xml</em> can be located <b>directly</b> under
- any folder declared in the class path. For example, if the
- class path reads "c:/java/jdk15/lib/rt.jar;c:/mylibs/" then
- the <em>logback.xml</em> file should be located directly
- under "c:/mylibs/", that is as
- "c:/mylibs/logback.xml". Placing it under a sub-folder of
- c:/mylibs/, say, c:/mylibs/other/, will not work.</p>
+ <p>Configuration files such as <em>logback.groovy</em>,
+ <em>logback-test.xml</em> or <em>logback.xml</em> can be
+ located <b>directly</b> under any folder declared in the
+ class path. For example, if the class path reads
+ "c:/java/jdk15/lib/rt.jar;c:/mylibs/" then the
+ <em>logback.xml</em> file should be located directly under
+ "c:/mylibs/", that is as "c:/mylibs/logback.xml". Placing it
+ under a sub-folder of c:/mylibs/, say, c:/mylibs/other/,
+ will not work.</p>
<p>For web-applications, configuration files can be placed
<b>directly</b> under <em>WEB-INF/classes/</em>.</p>
diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html
index ccf5099..3fea8db 100644
--- a/logback-site/src/site/pages/manual/configuration.html
+++ b/logback-site/src/site/pages/manual/configuration.html
@@ -72,9 +72,10 @@
</p>
<p>Logback can be configured either programmatically or with a
- configuration script (expressed in XML format). By the way,
- existing log4j users can convert their <em>log4j.properties</em>
- files to <em>logback.xml</em> using our <a
+ configuration script expressed in XML or Groovy format. By the
+ way, existing log4j users can convert their
+ <em>log4j.properties</em> files to <em>logback.xml</em> using our
+ <a
href="http://logback.qos.ch/translator/">PropertiesTranslator</a>
web-application.
</p>
@@ -86,7 +87,14 @@
<ol>
<li>
<p>Logback tries to find a file called
- <em>logback-test.xml</em> <a
+ <em>logback.groovy</em> <a
+ href="../faq.html#configFileLocation">in the
+ classpath</a>.</p>
+ </li>
+
+ <li>
+ <p>If no such file is found, logback tries to find a file
+ called <em>logback-test.xml</em> <a
href="../faq.html#configFileLocation">in the
classpath</a>.</p>
</li>
@@ -106,9 +114,9 @@
</ol>
- <p>The third and last step is meant to provide a default (but very
- basic) logging functionality in the absence of a configuration
- file.
+ <p>The fourth and last step is meant to provide a default (but
+ very basic) logging functionality in the absence of a
+ configuration file.
</p>
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 0df0912..d9e4272 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -26,6 +26,25 @@
the <a href="http://www.qos.ch/mailman/listinfo/announce">QOS.ch
announce</a> mailing list.</p>
+
+ <hr width="80%" align="center" />
+
+ <h3>June 2xth, 2010 - Release of version 0.9.22</h3>
+
+ <p>Logback now supports <a href="manual/groovy.html">configuration
+ files written in Groovy</a> which are more convenient than
+ configuration files written in XML. We have also developped a tool
+ to <a
+ href="http://logback.qos.ch/translator/asGroovy.html">automatically
+ migrate your logback.xml files to logback.groovy</a>.
+ </p>
+
+ <p>Fixed synchronization issue in <code>ConsoleAppender</code> as
+ reported in <a
+ href="http://jira.qos.ch/browse/LBCORE-158">LBCORE-158</a> by
+ David Roussel who also supplied a corrective patch.</p>
+
+
<hr width="80%" align="center" />
<h3>May 8th, 2010 - Release of version 0.9.21</h3>
diff --git a/logback-site/src/site/pages/reasonsToSwitch.html b/logback-site/src/site/pages/reasonsToSwitch.html
index b12bf23..454ca22 100644
--- a/logback-site/src/site/pages/reasonsToSwitch.html
+++ b/logback-site/src/site/pages/reasonsToSwitch.html
@@ -63,6 +63,29 @@
<p>Logback ships with over two hundred pages of constantly updated
documentation.</p>
+ <h3><a name="DSL" href="#DSL">Configuration files in XML or
+ Groovy</a></h3>
+
+ <p>The traditional way of configuring logback is via an XML
+ file. Most of the examples in the documentation use this XML
+ syntax. However, as of logback version 0.9.22, <a
+ href="manual/groovy.html">configuration files written in
+ Groovy</a> are also supported. Compared to XML, groovy style
+ configuration is more intuitive, consistent and have a much
+ shorter syntax.
+ </p>
+
+ <p>
+ There is also a <a
+ href="http://logback.qos.ch/translator/asGroovy.html">tool to
+ automatically migrate your logback.xml files to
+ logback.groovy</a>.
+ </p>
+
+ <p>We also plan to support configration files written in
+ Scala.</p>
+
+
<h3><a name="autoScan" href="#autoScan">Automatic reloading of
configuration files</a></h3>
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2d15361dfeeabfb8155ab94f…
http://github.com/ceki/logback/commit/2d15361dfeeabfb8155ab94fab624e73c07d4…
commit 2d15361dfeeabfb8155ab94fab624e73c07d4ca1
Merge: a052f15 4d88ab7
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Jun 17 10:20:52 2010 +0200
Merge branch 'lbcore_158'
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=4d88ab7333f6869bafb81cad…
http://github.com/ceki/logback/commit/4d88ab7333f6869bafb81cad50235c0668120…
commit 4d88ab7333f6869bafb81cad50235c0668120bf7
Merge: ee6dcb6 a425704
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Jun 17 10:16:51 2010 +0200
Merge http://github.com/diroussel/logback into lbcore_158
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=a4257048960bc721dc1c0be1…
http://github.com/ceki/logback/commit/a4257048960bc721dc1c0be167e22e7f0466e…
commit a4257048960bc721dc1c0be167e22e7f0466ea79
Author: David Roussel <dave(a)dvae.net>
Date: Fri Jun 11 22:30:20 2010 +0100
LBCORE-158 - fix for interleaved output to System.out when logback is not the only one writing to System.out (typo fix)
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
index b38f5f4..41ccfc2 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
@@ -30,7 +30,8 @@ public enum ConsoleTarget {
public void write(int b) throws IOException {
System.out.write(b);
}
- @Override+ public void write(byte b[]) throws IOException {
+ @Override
+ public void write(byte b[]) throws IOException {
System.out.write(b);
}
@Override
@@ -86,4 +87,4 @@ public enum ConsoleTarget {
public OutputStream getStream() {
return stream;
}
-}
\ No newline at end of file
+}
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=f18d4917d502f5d8703f83fc…
http://github.com/ceki/logback/commit/f18d4917d502f5d8703f83fc252928c4403cf…
commit f18d4917d502f5d8703f83fc252928c4403cfd92
Author: David Roussel <github(a)diroussel.xsmail.com>
Date: Fri Jun 11 13:59:54 2010 -0700
LBCORE-158 - fix for interleaved output to System.out when logback is not the only one writing to System.out
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
index ea9c30d..b38f5f4 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/ConsoleTarget.java
@@ -30,6 +30,13 @@ public enum ConsoleTarget {
public void write(int b) throws IOException {
System.out.write(b);
}
+ @Override+ public void write(byte b[]) throws IOException {
+ System.out.write(b);
+ }
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ System.out.write(b, off, len);
+ }
@Override
public void flush() throws IOException {
System.out.flush();
@@ -42,6 +49,14 @@ public enum ConsoleTarget {
System.err.write(b);
}
@Override
+ public void write(byte b[]) throws IOException {
+ System.err.write(b);
+ }
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {
+ System.err.write(b, off, len);
+ }
+ @Override
public void flush() throws IOException {
System.err.flush();
}
-----------------------------------------------------------------------
Summary of changes:
.../classic/gaffer/ComponentDelegate.groovy | 15 ++++---
.../gaffer/ConfigurationDelegateTest.groovy | 43 ++++++++++++++++----
.../qos/logback/core/joran/spi/ConsoleTarget.java | 19 ++++++++-
logback-site/src/site/pages/faq.html | 37 ++++++++++-------
.../src/site/pages/manual/configuration.html | 22 +++++++---
logback-site/src/site/pages/news.html | 19 +++++++++
logback-site/src/site/pages/reasonsToSwitch.html | 23 ++++++++++
7 files changed, 139 insertions(+), 39 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCORE-157) Initial log messages have changed after 0.9.19 version
by Andres Gomez Casanova (JIRA) 17 Jun '10
by Andres Gomez Casanova (JIRA) 17 Jun '10
17 Jun '10
Initial log messages have changed after 0.9.19 version
------------------------------------------------------
Key: LBCORE-157
URL: http://jira.qos.ch/browse/LBCORE-157
Project: logback-core
Issue Type: Bug
Components: Joran
Affects Versions: 0.9.19
Reporter: Andres Gomez Casanova
Assignee: Logback dev list
Sorry, I posted this message in SLF4J, and it is probably better here.
I'm developing an application for command line, and I use slf4j + logback for logging (http://db2sa.sourceforge.net/)
When using normally (not testing, not debugging), I have to show less messages in the screen, so the logging has not to be verbose. Just the important messages has to be shown.
I was using the version 0.9.15, and I updated my application to the version 0.9.21.
I saw, that the layout has to be changed to encoder, and I did it in the xml configuration file.
However, I'm facing a problem when starting the application. The logger is showing all the configuration phase, and I'm sure that the internal log is not in debug:
<configuration debug="false">
It seems that the new version does not take in account this property.
I searched the problematic version, and this issue was introduced in the version 0.9.19.
I created an example for showing the difference when loading the configuration between 0.9.18 and 0.9.19.
It can be executed by running the .bat
--
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
3

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-9-ga052f15
by git-noreply@pixie.qos.ch 17 Jun '10
by git-noreply@pixie.qos.ch 17 Jun '10
17 Jun '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, master has been updated
via a052f15d09636698c96fcdb753da3270f5c01b11 (commit)
from ee6dcb691896b71fcc425980f6f6f07aa7fcc611 (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=a052f15d09636698c96fcdb7…
http://github.com/ceki/logback/commit/a052f15d09636698c96fcdb753da3270f5c01…
commit a052f15d09636698c96fcdb753da3270f5c01b11
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Thu Jun 17 10:15:07 2010 +0200
Added multiple buffer tracking capability to SMTPAppender
diff --git a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java b/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java
index 13477e9..4d48cc8 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/net/SMTPAppender.java
@@ -34,9 +34,6 @@ import ch.qos.logback.core.net.SMTPAppenderBase;
public class SMTPAppender extends SMTPAppenderBase<AccessEvent> {
static final String DEFAULT_SUBJECT_PATTERN = "%m";
-
- private int bufferSize = 512;
- protected CyclicBuffer<AccessEvent> cb = new CyclicBuffer<AccessEvent>(bufferSize);
/**
* The default constructor will instantiate the appender with a
@@ -56,15 +53,14 @@ public class SMTPAppender extends SMTPAppenderBase<AccessEvent> {
/**
* Perform SMTPAppender specific appending actions, mainly adding the event to
- * a cyclic buffer.
+ * the appropriate cyclic buffer.
*/
- protected void subAppend(AccessEvent event) {
+ protected void subAppend(CyclicBuffer<AccessEvent> cb, AccessEvent event) {
cb.add(event);
- // addInfo("Added event to the cyclic buffer: " + event.getMessage());
}
@Override
- protected void fillBuffer(StringBuffer sbuf) {
+ protected void fillBuffer(CyclicBuffer<AccessEvent> cb, StringBuffer sbuf) {
int len = cb.length();
for (int i = 0; i < len; i++) {
// sbuf.append(MimeUtility.encodeText(layout.format(cb.get())));
@@ -73,25 +69,6 @@ public class SMTPAppender extends SMTPAppenderBase<AccessEvent> {
}
}
- /**
- * The <b>BufferSize</b> option takes a positive integer representing the
- * maximum number of logging events to collect in a cyclic buffer. When the
- * <code>BufferSize</code> is reached, oldest events are deleted as new
- * events are added to the buffer. By default the size of the cyclic buffer is
- * 512 events.
- */
- public void setBufferSize(int bufferSize) {
- this.bufferSize = bufferSize;
- cb.resize(bufferSize);
- }
-
- /**
- * Returns value of the <b>BufferSize</b> option.
- */
- public int getBufferSize() {
- return bufferSize;
- }
-
@Override
protected Layout<AccessEvent> makeSubjectLayout(String subjectStr) {
if(subjectStr == null) {
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java
index caf0036..c30e24c 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java
@@ -38,7 +38,7 @@ public class SMTPAppender extends SMTPAppenderBase<ILoggingEvent> {
static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m";
private int bufferSize = 512;
- protected CyclicBuffer<ILoggingEvent> cb = new CyclicBuffer<ILoggingEvent>(bufferSize);
+ //protected CyclicBuffer<ILoggingEvent> cb = new CyclicBuffer<ILoggingEvent>(bufferSize);
/**
* The default constructor will instantiate the appender with a
@@ -72,41 +72,20 @@ public class SMTPAppender extends SMTPAppenderBase<ILoggingEvent> {
* Perform SMTPAppender specific appending actions, mainly adding the event to
* a cyclic buffer.
*/
- protected void subAppend(ILoggingEvent event) {
+ protected void subAppend(CyclicBuffer<ILoggingEvent> cb, ILoggingEvent event) {
event.prepareForDeferredProcessing();
cb.add(event);
- // addInfo("Added event to the cyclic buffer: " + event.getMessage());
}
@Override
- protected void fillBuffer(StringBuffer sbuf) {
+ protected void fillBuffer(CyclicBuffer<ILoggingEvent> cb, StringBuffer sbuf) {
int len = cb.length();
for (int i = 0; i < len; i++) {
- // sbuf.append(MimeUtility.encodeText(layout.format(cb.get())));
ILoggingEvent event = cb.get();
sbuf.append(layout.doLayout(event));
}
}
- /**
- * The <b>BufferSize</b> option takes a positive integer representing the
- * maximum number of logging events to collect in a cyclic buffer. When the
- * <code>BufferSize</code> is reached, oldest events are deleted as new
- * events are added to the buffer. By default the size of the cyclic buffer is
- * 512 events.
- */
- public void setBufferSize(int bufferSize) {
- this.bufferSize = bufferSize;
- cb.resize(bufferSize);
- }
-
- /**
- * Returns value of the <b>BufferSize</b> option.
- */
- public int getBufferSize() {
- return bufferSize;
- }
-
@Override
protected Layout<ILoggingEvent> makeSubjectLayout(String subjectStr) {
if(subjectStr == null) {
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/net/DilutedSMTPAppenderTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/net/DilutedSMTPAppenderTest.java
index 3e605fc..76b3ae0 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/net/DilutedSMTPAppenderTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/net/DilutedSMTPAppenderTest.java
@@ -20,6 +20,8 @@ import static org.junit.Assert.fail;
import javax.mail.Address;
import javax.mail.MessagingException;
+import ch.qos.logback.core.helpers.CyclicBuffer;
+import ch.qos.logback.core.spi.CyclicBufferTracker;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -34,11 +36,15 @@ import ch.qos.logback.core.Layout;
public class DilutedSMTPAppenderTest {
SMTPAppender appender;
+ CyclicBufferTracker cbTracker;
+ CyclicBuffer cb;
@Before
public void setUp() throws Exception {
LoggerContext lc = new LoggerContext();
appender = new SMTPAppender();
+ cbTracker = appender.getCyclicBufferTracker();
+ cb = cbTracker.get("", 0);
appender.setContext(lc);
appender.setName("smtp");
appender.setFrom("user(a)host.dom");
@@ -92,8 +98,8 @@ public class DilutedSMTPAppenderTest {
LoggingEvent event = new LoggingEvent();
event.setThreadName("thead name");
event.setLevel(Level.DEBUG);
- appender.subAppend(event);
- assertEquals(1, appender.cb.length());
+ appender.subAppend(cb, event);
+ assertEquals(1, cb.length());
}
@Test
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 8b7661d..ef09428 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
@@ -43,7 +43,6 @@ public class ConsoleAppender<E> extends OutputStreamAppender<E> {
public void setTarget(String value) {
ConsoleTarget t = ConsoleTarget.findByName(value.trim());
if (t == null) {
- System.out.println("**************");
targetWarn(value);
} else {
target = t;
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 699483f..9d65b75 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
@@ -115,4 +115,5 @@ public class CoreConstants {
public static int BYTES_PER_INT = 4;
+ public static final int MILLIS_IN_ONE_SECOND = 1000;
}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index 7ca6684..43e34e6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -34,6 +34,11 @@ import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.Layout;
import ch.qos.logback.core.boolex.EvaluationException;
import ch.qos.logback.core.boolex.EventEvaluator;
+import ch.qos.logback.core.helpers.CyclicBuffer;
+import ch.qos.logback.core.sift.DefaultDiscriminator;
+import ch.qos.logback.core.sift.Discriminator;
+import ch.qos.logback.core.spi.CyclicBufferTracker;
+import ch.qos.logback.core.spi.CyclicBufferTrackerImpl;
import ch.qos.logback.core.util.ContentTypeUtil;
import ch.qos.logback.core.util.OptionHelper;
@@ -43,20 +48,20 @@ import ch.qos.logback.core.util.OptionHelper;
/**
* An abstract class that provides support for sending events to an email
* address.
- *
- * <p>
+ * <p/>
+ * <p/>
* See http://logback.qos.ch/manual/appenders.html#SMTPAppender for further
* documentation.
- *
+ *
* @author Ceki Gülcü
* @author Sébastien Pennec
*/
public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
protected Layout<E> subjectLayout;
-
+
protected Layout<E> layout;
-
+
private List<String> toList = new ArrayList<String>();
private String from;
private String subjectStr = null;
@@ -74,15 +79,17 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
protected EventEvaluator<E> eventEvaluator;
+ protected Discriminator<E> discriminator = new DefaultDiscriminator<E>();
+ protected CyclicBufferTracker<E> cbTracker = new CyclicBufferTrackerImpl<E>();
+
private int errorCount = 0;
/**
* return a layout for the subjet string as appropriate for the module. If the
* subjectStr parameter is null, then a default value for subjectStr should be
* used.
- *
+ *
* @param subjectStr
- *
* @return a layout as appropriate for the module
*/
abstract protected Layout<E> makeSubjectLayout(String subjectStr);
@@ -152,26 +159,31 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
return;
}
- subAppend(eventObject);
+
+ String key = discriminator.getDiscriminatingValue(eventObject);
+
+ CyclicBuffer<E> cb = cbTracker.get(key, System.currentTimeMillis());
+
+ subAppend(cb, eventObject);
try {
if (eventEvaluator.evaluate(eventObject)) {
- sendBuffer(eventObject);
+ sendBuffer(cb, eventObject);
}
} catch (EvaluationException ex) {
- errorCount ++;
+ errorCount++;
if (errorCount < CoreConstants.MAX_ERROR_COUNT) {
addError("SMTPAppender's EventEvaluator threw an Exception-", ex);
}
}
}
- abstract protected void subAppend(E eventObject);
+ abstract protected void subAppend(CyclicBuffer<E> cb, E eventObject);
/**
* This method determines if there is a sense in attempting to append.
- *
- * <p>
+ * <p/>
+ * <p/>
* It checks whether there is a set output target and also if there is a set
* layout. If these checks fail, then the boolean value <code>false</code> is
* returned.
@@ -179,7 +191,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
public boolean checkEntryConditions() {
if (!this.started) {
addError("Attempting to append to a non-started appender: "
- + this.getName());
+ + this.getName());
return false;
}
@@ -195,8 +207,8 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
if (this.layout == null) {
addError("No layout set for appender named ["
- + name
- + "]. For more information, please visit http://logback.qos.ch/codes.html#smtp_no_layout");
+ + name
+ + "]. For more information, please visit http://logback.qos.ch/codes.html#smtp_no_layout");
return false;
}
return true;
@@ -243,7 +255,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
/**
* Send the contents of the cyclic buffer as an e-mail message.
*/
- protected void sendBuffer(E lastEventObject) {
+ protected void sendBuffer(CyclicBuffer<E> cb, E lastEventObject) {
// Note: this code already owns the monitor for this
// appender. This frees us from needing to synchronize on 'cb'.
@@ -260,7 +272,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
if (presentationHeader != null) {
sbuf.append(presentationHeader);
}
- fillBuffer(sbuf);
+ fillBuffer(cb, sbuf);
String presentationFooter = layout.getPresentationFooter();
if (presentationFooter != null) {
sbuf.append(presentationFooter);
@@ -272,14 +284,14 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
if (subjectLayout != null) {
mimeMsg.setSubject(subjectLayout.doLayout(lastEventObject),
- charsetEncoding);
+ charsetEncoding);
}
String contentType = layout.getContentType();
if (ContentTypeUtil.isTextual(contentType)) {
part.setText(sbuf.toString(), charsetEncoding, ContentTypeUtil
- .getSubType(contentType));
+ .getSubType(contentType));
} else {
part.setContent(sbuf.toString(), layout.getContentType());
}
@@ -295,7 +307,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
}
}
- abstract protected void fillBuffer(StringBuffer sbuf);
+ abstract protected void fillBuffer(CyclicBuffer<E> cb, StringBuffer sbuf);
/**
* Returns value of the <b>From</b> option.
@@ -344,7 +356,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
/**
* The port where the SMTP server is running. Default value is 25.
- *
+ *
* @param port
*/
public void setSMTPPort(int port) {
@@ -352,13 +364,29 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
}
/**
- * @see #setSMTPPort(int)
* @return
+ * @see #setSMTPPort(int)
*/
public int getSMTPPort() {
return smtpPort;
}
+ public CyclicBufferTracker<E> getCyclicBufferTracker() {
+ return cbTracker;
+ }
+
+ public void setCyclicBufferTracker(CyclicBufferTracker<E> cbTracker) {
+ this.cbTracker = cbTracker;
+ }
+
+ public Discriminator<E> getDiscriminator() {
+ return discriminator;
+ }
+
+ public void setDiscriminator(Discriminator<E> discriminator) {
+ this.discriminator = discriminator;
+ }
+
/**
* The <b>To</b> option takes a string value which should be an e-mail address
* of one of the recipients.
@@ -368,11 +396,13 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
}
// for testing purpose only
+
public Message getMessage() {
return mimeMsg;
}
// for testing purpose only
+
public void setMessage(MimeMessage msg) {
this.mimeMsg = msg;
}
@@ -420,17 +450,17 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
}
/**
- * @see #setCharsetEncoding(String)
* @return the charset encoding value
+ * @see #setCharsetEncoding(String)
*/
public String getCharsetEncoding() {
return charsetEncoding;
- }
+ }
/**
* Set the character set encoding of the outgoing email messages. The default
* encoding is "UTF-8" which usually works well for most purposes.
- *
+ *
* @param charsetEncoding
*/
public void setCharsetEncoding(String charsetEncoding) {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
index 6e75c85..fa6c5c5 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTracker.java
@@ -16,11 +16,11 @@ package ch.qos.logback.core.sift;
import java.util.List;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
public interface AppenderTracker<E> {
- static int MILLIS_IN_ONE_SECOND = 1000;
- static int THRESHOLD = 30 * 60 * MILLIS_IN_ONE_SECOND; // 30 minutes
+ static int THRESHOLD = 30 * 60 * CoreConstants.MILLIS_IN_ONE_SECOND; // 30 minutes
void put(String key, Appender<E> value, long timestamp);
Appender<E> get(String key, long timestamp);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
index 4e388b2..050acda 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
/**
* Track appenders by a key. When an appender is not used for
@@ -62,7 +63,7 @@ public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
public synchronized void stopStaleAppenders(long now) {
- if (lastCheck + MILLIS_IN_ONE_SECOND > now) {
+ if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
return;
}
lastCheck = now;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java
new file mode 100644
index 0000000..a1354d9
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java
@@ -0,0 +1,46 @@
+/**
+ * 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.sift;
+
+import ch.qos.logback.core.sift.Discriminator;
+
+/**
+ * @author Ceki Gücü
+ */
+public class DefaultDiscriminator<E> implements Discriminator<E> {
+
+ static public final String DEFAULT = "default";
+
+ boolean started = false;
+
+ public String getDiscriminatingValue(E e) {
+ return DEFAULT;
+ }
+
+ public String getKey() {
+ return DEFAULT;
+ }
+
+ public void start() {
+ started = true;
+ }
+
+ public void stop() {
+ started = false;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
new file mode 100644
index 0000000..db82b74
--- /dev/null
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
@@ -0,0 +1,65 @@
+/**
+ * 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.spi;
+
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.helpers.CyclicBuffer;
+
+/**
+ * An interface for tracking cyclic buffers by key.
+ *
+ * @author Ceki Gücü
+ */
+public interface CyclicBufferTracker<E> {
+
+ public static int DEFAULT_BUFFER_SIZE = 256;
+ public static int DEFAULT_NUMBER_OF_BUFFERS = 64;
+
+ static int THRESHOLD = 30 * 60 * CoreConstants.MILLIS_IN_ONE_SECOND; // 30 minutes
+
+ public int getBufferSize();
+
+ public void setBufferSize(int size);
+
+
+ public int getMaxNumberOfBuffers();
+
+ /**
+ * Set the maximum number of tracked buffers. After reaching the maximum number of
+ * buffers, the creation of a new buffer implies the removal of the least recently
+ * used buffer.
+ *
+ * @param maxNumBuffers
+ */
+ public void setMaxNumberOfBuffers(int maxNumBuffers);
+
+
+ /**
+ * Get the cyclic buffer identified by 'key', updating its timestamp in the process.
+ * If there is no such buffer, create it. If the current number of buffers is
+ * above or equal to 'maxNumBuffers' then the least recently accessed buffer is removed.
+ *
+ * @param key
+ * @param timestamp
+ * @return
+ */
+ CyclicBuffer<E> get(String key, long timestamp);
+
+ /**
+ * Clear (and detach) buffers which are stale.
+ *
+ * @param now
+ */
+ void clearStaleBuffers(long now);
+}
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
similarity index 59%
copy from logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
copy to logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
index 4e388b2..f71813c 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/AppenderTrackerImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
@@ -1,6 +1,6 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ * 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
@@ -11,48 +11,57 @@
* 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.sift;
+package ch.qos.logback.core.spi;
+
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.helpers.CyclicBuffer;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import ch.qos.logback.core.Appender;
-
/**
- * Track appenders by a key. When an appender is not used for
- * longer than THRESHOLD, stop it.
- * @author Ceki Gulcu
+ * @author Ceki Gücü
*/
-public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
+public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
+
+ int bufferSize = DEFAULT_BUFFER_SIZE;
+ int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS;
+ int bufferCount = 0;
- Map<String, Entry> map = new HashMap<String, Entry>();
-
- Entry head; // least recently used entries are towards the head
- Entry tail; // most recently used entries are towards the tail
+ private Map<String, Entry> map = new HashMap<String, Entry>();
+ private Entry head; // least recently used entries are towards the head
+ private Entry tail; // most recently used entries are towards the tail
long lastCheck = 0;
- AppenderTrackerImpl() {
+ public CyclicBufferTrackerImpl() {
head = new Entry(null, null, 0);
tail = head;
}
+ public int getBufferSize() {
+ return bufferSize;
+ }
- public synchronized void put(String key, Appender<E> value, long timestamp) {
- Entry entry = map.get(key);
- if (entry == null) {
- entry = new Entry(key, value, timestamp);
- map.put(key, entry);
- }
- moveToTail(entry);
+ public void setBufferSize(int size) {
+ }
+
+ public int getMaxNumberOfBuffers() {
+ return maxNumBuffers;
}
- public synchronized Appender<E> get(String key, long timestamp) {
+ public void setMaxNumberOfBuffers(int maxNumBuffers) {
+ this.maxNumBuffers = maxNumBuffers;
+ }
+
+ public CyclicBuffer<E> get(String key, long timestamp) {
Entry existing = map.get(key);
if (existing == null) {
- return null;
+ CyclicBuffer<E> cb = processNewEntry(key, timestamp);
+ return cb;
} else {
existing.setTimestamp(timestamp);
moveToTail(existing);
@@ -60,60 +69,25 @@ public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
}
}
-
- public synchronized void stopStaleAppenders(long now) {
- if (lastCheck + MILLIS_IN_ONE_SECOND > now) {
- return;
- }
- lastCheck = now;
- while (head.value != null && isEntryStale(head,now)) {
- Appender<E> appender = head.value;
- appender.stop();
+ private CyclicBuffer<E> processNewEntry(String key, long timestamp) {
+ CyclicBuffer<E> cb = new CyclicBuffer<E>(bufferSize);
+ Entry entry = new Entry(key, cb, timestamp);
+ map.put(key, entry);
+ bufferCount++;
+ rearrangeTailLinks(entry);
+ if (bufferCount >= maxNumBuffers) {
removeHead();
}
- }
-
- /**
- * @since 0.9.19
- * @param key
- */
- public synchronized void stopAndRemoveNow(String key) {
- Entry e = head;
- Entry found = null;
- while (e != tail) {
- if(key.equals(e.key)) {
- found = e;
- break;
- }
- e = e.next;
- }
- if(found != null) {
- rearrangePreexistingLinks(e);
- map.remove(key);
- Appender<E> appender = e.value;
- appender.stop();
- }
- }
-
- public List<String> keyList() {
- List<String> result = new LinkedList<String>();
- Entry e = head;
- while (e != tail) {
- result.add(e.key);
- e = e.next;
- }
- return result;
- }
-
-
- final private boolean isEntryStale(Entry entry, long now) {
- return ((entry.timestamp + THRESHOLD) < now);
+ return cb;
}
-
private void removeHead() {
- // System.out.println("RemoveHead called");
+ CyclicBuffer cb = head.value;
+ if (cb != null) {
+ cb.clear();
+ }
map.remove(head.key);
+ bufferCount--;
head = head.next;
head.prev = null;
}
@@ -135,6 +109,32 @@ public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
}
}
+
+ public synchronized void clearStaleBuffers(long now) {
+ if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+ return;
+ }
+ lastCheck = now;
+ while (head.value != null && isEntryStale(head, now)) {
+ CyclicBuffer<E> cb = head.value;
+ cb.clear();
+ removeHead();
+ }
+ }
+
+ final private boolean isEntryStale(Entry entry, long now) {
+ return ((entry.timestamp + THRESHOLD) < now);
+ }
+
+ List<String> keyList() {
+ List<String> result = new LinkedList<String>();
+ Entry e = head;
+ while (e != tail) {
+ result.add(e.key);
+ e = e.next;
+ }
+ return result;
+ }
private void rearrangeTailLinks(Entry e) {
if (head == tail) {
head = e;
@@ -148,48 +148,22 @@ public class AppenderTrackerImpl<E> implements AppenderTracker<E> {
tail.prev = e;
}
- public void dump() {
- Entry e = head;
- System.out.print("N:");
- while (e != null) {
- // System.out.print(e+"->");
- System.out.print(e.key + ", ");
- e = e.next;
- }
- System.out.println();
- }
-
-
-
- public List<Appender<E>> valueList() {
- List<Appender<E>> result = new LinkedList<Appender<E>>();
- Entry e = head;
- while (e != tail) {
- result.add(e.value);
- e = e.next;
- }
- return result;
- }
-
// ================================================================
+
private class Entry {
Entry next;
Entry prev;
String key;
- Appender<E> value;
+ CyclicBuffer<E> value;
long timestamp;
- Entry(String k, Appender<E> v, long timestamp) {
+ Entry(String k, CyclicBuffer<E> v, long timestamp) {
this.key = k;
this.value = v;
this.timestamp = timestamp;
}
-// public long getTimestamp() {
-// return timestamp;
-// }
-
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
index 3b8e546..aa69266 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/AppenderTrackerTImpl.java
@@ -19,6 +19,7 @@ import java.util.LinkedList;
import java.util.List;
import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
import ch.qos.logback.core.sift.AppenderTracker;
/**
@@ -61,7 +62,7 @@ public class AppenderTrackerTImpl implements AppenderTracker<Object> {
}
synchronized public void stopStaleAppenders(long timestamp) {
- if (lastCheck + MILLIS_IN_ONE_SECOND > timestamp) {
+ if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > timestamp) {
return;
}
lastCheck = timestamp;
diff --git a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java
index 600f41c..7f22b9e 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/sift/tracker/TEntry.java
@@ -1,6 +1,6 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
+ * 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
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java
new file mode 100644
index 0000000..6b9ee28
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java
@@ -0,0 +1,46 @@
+package ch.qos.logback.core.spi;
+
+import ch.qos.logback.core.helpers.CyclicBuffer;
+import ch.qos.logback.core.sift.AppenderTrackerImpl;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertNotNull;
+
+/**
+ * @author Ceki Gücü
+ */
+public class CyclicBufferTrackerImplTest {
+
+
+ CyclicBufferTrackerImpl<Object> tracker = new CyclicBufferTrackerImpl<Object>();
+ String key = "a";
+
+ @Test
+ public void empty0() {
+ long now = 3000;
+ tracker.clearStaleBuffers(now);
+ assertEquals(0, tracker.keyList().size());
+ }
+
+ @Test
+ public void empty1() {
+ long now = 3000;
+ assertNotNull(tracker.get(key, now++));
+ now += CyclicBufferTracker.THRESHOLD+1000;
+ tracker.clearStaleBuffers(now);
+ assertEquals(0, tracker.keyList().size());
+ assertNotNull(tracker.get(key, now++));
+ }
+
+ @Test
+ public void smoke() {
+ long now = 3000;
+ CyclicBuffer<Object> cb = tracker.get(key, now);
+ assertEquals(cb, tracker.get(key, now++));
+ now += AppenderTrackerImpl.THRESHOLD+1000;
+ tracker.clearStaleBuffers(now);
+ assertEquals(0, tracker.keyList().size());
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java
new file mode 100644
index 0000000..3d3e000
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java
@@ -0,0 +1,100 @@
+/**
+ * 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.spi;
+
+import java.util.*;
+
+/**
+ * @author Ceki Gücü
+ */
+public class CyclicBufferTrackerSimulator {
+
+ CyclicBufferTrackerImpl<Object> realAppenderTracker = new CyclicBufferTrackerImpl<Object>();
+ CyclicBufferTrackerImpl t_appenderTracker = new CyclicBufferTrackerImpl();
+
+ List<SimulationEvent> scenario = new ArrayList<SimulationEvent>();
+ List<String> keySpace = new ArrayList<String>();
+ int maxTimestampInc;
+ Random randomKeyGen = new Random(100);
+ Random random = new Random(11234);
+
+ CyclicBufferTrackerSimulator(int keySpaceLen, int maxTimestampInc) {
+ this.maxTimestampInc = maxTimestampInc;
+ Map<String, String> checkMap = new HashMap<String, String>();
+ for (int i = 0; i < keySpaceLen; i++) {
+ String k = getRandomKeyStr();
+ if (checkMap.containsKey(k)) {
+ System.out.println("random key collision occured");
+ k += "" + i;
+ }
+ keySpace.add(k);
+ checkMap.put(k, k);
+ }
+
+ }
+
+ private String getRandomKeyStr() {
+ int ri = randomKeyGen.nextInt();
+ String s = String.format("%X", ri);
+ return s;
+ }
+
+ void buildScenario(int simLen) {
+ long timestamp = 30000;
+ int keySpaceLen = keySpace.size();
+ for (int i = 0; i < simLen; i++) {
+ int index = random.nextInt(keySpaceLen);
+ timestamp += random.nextInt(maxTimestampInc);
+ String key = keySpace.get(index);
+ scenario.add(new SimulationEvent(key, timestamp));
+ }
+ }
+
+ public void dump() {
+ for (SimulationEvent simeEvent : scenario) {
+ System.out.println(simeEvent);
+ }
+ }
+
+
+ void play(SimulationEvent simulationEvent,
+ CyclicBufferTracker<Object> tracker) {
+ String key = simulationEvent.key;
+ long timestamp = simulationEvent.timestamp;
+ tracker.get(key, timestamp);
+ }
+
+ public void simulate() {
+ for (SimulationEvent simeEvent : scenario) {
+ play(simeEvent, realAppenderTracker);
+ play(simeEvent, t_appenderTracker);
+ }
+ }
+
+ // =========================================================================
+
+ class SimulationEvent {
+ final public String key;
+ final public long timestamp;
+
+ public SimulationEvent(String key, long timestamp) {
+ this.key = key;
+ this.timestamp = timestamp;
+ }
+
+ public String toString() {
+ return "Event: k=" + key + ", timestamp=" + timestamp;
+ }
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
new file mode 100644
index 0000000..fd56075
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
@@ -0,0 +1,150 @@
+package ch.qos.logback.core.spi;
+
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.helpers.CyclicBuffer;
+import ch.qos.logback.core.sift.tracker.TEntry;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author Ceki Gücü
+ */
+public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
+
+ int bufferSize = DEFAULT_BUFFER_SIZE;
+ int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS;
+ int bufferCount = 0;
+
+
+ List<TEntry> entryList = new LinkedList<TEntry>();
+ long lastCheck = 0;
+
+ public int getBufferSize() {
+ return bufferSize;
+ }
+
+ public void setBufferSize(int size) {
+ }
+
+ public int getMaxNumberOfBuffers() {
+ return maxNumBuffers;
+ }
+
+ public void setMaxNumberOfBuffers(int maxNumBuffers) {
+ this.maxNumBuffers = maxNumBuffers;
+ }
+
+ private TEntry getEntry(String k) {
+ for (int i = 0; i < entryList.size(); i++) {
+ TEntry te = entryList.get(i);
+ if (te.key.equals(k)) {
+ return te;
+ }
+ }
+ return null;
+ }
+
+ public CyclicBuffer<E> get(String key, long timestamp) {
+ TEntry te = getEntry(key);
+ if (te == null) {
+ CyclicBuffer<E> cb = new CyclicBuffer<E>(bufferSize);
+ te = new TEntry<E>(key, cb, timestamp);
+ entryList.add(te);
+ return cb;
+ } else {
+ te.timestamp = timestamp;
+ Collections.sort(entryList);
+ return te.value;
+ }
+
+ }
+
+ final private boolean isEntryStale(TEntry entry, long now) {
+ return ((entry.timestamp + THRESHOLD) < now);
+ }
+
+ public void clearStaleBuffers(long now) {
+ if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+ return;
+ }
+ lastCheck = now;
+ Collections.sort(entryList);
+ while (entryList.size() != 0 && isEntryStale(entryList.get(0), now)) {
+ entryList.remove(0);
+ }
+ }
+
+ // ==================================================================
+
+ private class TEntry<E> implements Comparable {
+ TEntry next;
+ TEntry prev;
+
+ String key;
+ CyclicBuffer<E> value;
+ long timestamp;
+
+ TEntry(String k, CyclicBuffer<E> v, long timestamp) {
+ this.key = k;
+ this.value = v;
+ this.timestamp = timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ return result;
+ }
+
+ public int compareTo(Object o) {
+ if (!(o instanceof TEntry)) {
+ throw new IllegalArgumentException("arguments must be of type " + TEntry.class);
+ }
+
+ TEntry other = (TEntry) o;
+ if (timestamp > other.timestamp) {
+ return 1;
+ }
+ if (timestamp == other.timestamp) {
+ return 0;
+ }
+ return -1;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final TEntry other = (TEntry) obj;
+ if (key == null) {
+ if (other.key != null)
+ return false;
+ } else if (!key.equals(other.key))
+ return false;
+ if (value == null) {
+ if (other.value != null)
+ return false;
+ } else if (!value.equals(other.value))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + key + ", " + value + ")";
+ }
+ }
+}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java
index 991ffff..804ba0b 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/PackageTest.java
@@ -18,7 +18,8 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
-(a)Suite.SuiteClasses({AppenderAttachableImplTest.class ,AppenderAttachableImplLockTest.class})
+(a)Suite.SuiteClasses({AppenderAttachableImplTest.class, AppenderAttachableImplLockTest.class,
+ CyclicBufferTrackerImplTest.class, ScenarioBasedCyclicBufferTrackerTest.class})
public class PackageTest {
}
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java b/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java
new file mode 100644
index 0000000..e48e4df
--- /dev/null
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.spi;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertNotNull;
+
+/**
+ * @author Ceki Gücü
+ */
+public class ScenarioBasedCyclicBufferTrackerTest {
+
+ CyclicBufferTrackerSimulator simulator;
+
+ void verify() {
+ CyclicBufferTrackerImpl<Object> at = simulator.realAppenderTracker;
+ CyclicBufferTrackerImpl<Object> t_at = simulator.t_appenderTracker;
+ assertEquals(t_at.keyList(), at.keyList());
+ }
+
+ @Test
+ public void shortTest() {
+ simulator = new CyclicBufferTrackerSimulator(64, 500);
+ simulator.buildScenario(200);
+ simulator.simulate();
+ verify();
+ }
+
+ @Test
+ public void mediumTest() {
+ simulator = new CyclicBufferTrackerSimulator(128, CyclicBufferTracker.THRESHOLD / 2);
+ simulator.buildScenario(20000);
+ simulator.simulate();
+ verify();
+ }
+
+ @Test
+ public void longTest() {
+ simulator = new CyclicBufferTrackerSimulator(128, CyclicBufferTracker.THRESHOLD / 2);
+ simulator.buildScenario(200000);
+ simulator.simulate();
+ verify();
+ }
+}
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/access/net/SMTPAppender.java | 29 +---
.../ch/qos/logback/classic/net/SMTPAppender.java | 27 +---
.../classic/net/DilutedSMTPAppenderTest.java | 10 +-
.../java/ch/qos/logback/core/ConsoleAppender.java | 1 -
.../java/ch/qos/logback/core/CoreConstants.java | 1 +
.../ch/qos/logback/core/net/SMTPAppenderBase.java | 82 +++++++---
.../ch/qos/logback/core/sift/AppenderTracker.java | 4 +-
.../qos/logback/core/sift/AppenderTrackerImpl.java | 3 +-
.../logback/core/sift/DefaultDiscriminator.java} | 26 +++-
.../qos/logback/core/spi/CyclicBufferTracker.java | 65 ++++++++
.../CyclicBufferTrackerImpl.java} | 172 +++++++++-----------
.../core/sift/tracker/AppenderTrackerTImpl.java | 3 +-
.../ch/qos/logback/core/sift/tracker/TEntry.java | 2 +-
.../core/spi/CyclicBufferTrackerImplTest.java | 46 ++++++
.../core/spi/CyclicBufferTrackerSimulator.java | 100 ++++++++++++
.../core/spi/CyclicBufferTracker_TImpl.java | 150 +++++++++++++++++
.../java/ch/qos/logback/core/spi/PackageTest.java | 3 +-
.../spi/ScenarioBasedCyclicBufferTrackerTest.java | 58 +++++++
18 files changed, 591 insertions(+), 191 deletions(-)
copy logback-core/src/{test/java/ch/qos/logback/core/joran/spi/DoNotAutoStart.java => main/java/ch/qos/logback/core/sift/DefaultDiscriminator.java} (56%)
create mode 100644 logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
copy logback-core/src/main/java/ch/qos/logback/core/{sift/AppenderTrackerImpl.java => spi/CyclicBufferTrackerImpl.java} (59%)
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerImplTest.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTrackerSimulator.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
create mode 100644 logback-core/src/test/java/ch/qos/logback/core/spi/ScenarioBasedCyclicBufferTrackerTest.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0
Git repo broken
---------------
Key: LBSITE-40
URL: http://jira.qos.ch/browse/LBSITE-40
Project: logback-site
Issue Type: Bug
Components: Documentation
Reporter: David Roussel
Assignee: Logback dev list
Priority: Minor
The web page at http://logback.qos.ch/repos.html says the main git repo can be cloned by doing:
{code}
git clone http://git.qos.ch/logback/
{code}
This fails with:
{code}
warning: remote HEAD refers to nonexistent ref, unable to checkout.
{code}
And indeed http://git.qos.ch/logback/refs/heads/master points to 521dfe290dfa34fadb247ee63607a0cddaaf181f
which doesn't seem to exist in http://git.qos.ch/logback/objects/
cloning from github works fine
--
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
1

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-8-gee6dcb6
by git-noreply@pixie.qos.ch 15 Jun '10
by git-noreply@pixie.qos.ch 15 Jun '10
15 Jun '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, master has been updated
via ee6dcb691896b71fcc425980f6f6f07aa7fcc611 (commit)
from 459e776d0ad4954ca36ee26210339ccf61f96f96 (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=ee6dcb691896b71fcc425980…
http://github.com/ceki/logback/commit/ee6dcb691896b71fcc425980f6f6f07aa7fcc…
commit ee6dcb691896b71fcc425980f6f6f07aa7fcc611
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Tue Jun 15 15:22:36 2010 +0200
- modified comment
diff --git a/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java b/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java
index 5bf0c71..1465c1d 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/sift/Discriminator.java
@@ -37,7 +37,9 @@ public interface Discriminator<E> extends LifeCycle {
String getDiscriminatingValue(E e);
/**
- *
+ * The key or variable name under which the discriminating value should be
+ * exported into the host environment.
+ *
* @return
*/
String getKey();
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/core/sift/Discriminator.java | 4 +++-
1 files changed, 3 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_0.9.21-7-g459e776
by git-noreply@pixie.qos.ch 14 Jun '10
by git-noreply@pixie.qos.ch 14 Jun '10
14 Jun '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, master has been updated
via 459e776d0ad4954ca36ee26210339ccf61f96f96 (commit)
from c641f97153aecc6791e95cad237ae8706f28102e (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=459e776d0ad4954ca36ee262…
http://github.com/ceki/logback/commit/459e776d0ad4954ca36ee26210339ccf61f96…
commit 459e776d0ad4954ca36ee26210339ccf61f96f96
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Mon Jun 14 21:23:17 2010 +0200
- upgraded to ant-plugin version 1.4
- simplified logback-classic/osgi-build.xml
- added logback-classic/integration.xml in order to test initialization without groovy.jar on the classpath
diff --git a/logback-classic/integration.xml b/logback-classic/integration.xml
new file mode 100644
index 0000000..a8a5b3a
--- /dev/null
+++ b/logback-classic/integration.xml
@@ -0,0 +1,41 @@
+<project name="integration" default="testAll" basedir=".">
+
+ <!--
+ This build file is usually run indirectly via Maven.
+
+ When running this build file through Ant directly, you must
+ define the slf4jVersion property on the command line, e.g.:
+
+ ant -Dslf4jVersion=1.5.4-SNAPSHOT
+ -->
+
+ <echo message="slf4j.version: ${slf4j.version}" />
+
+ <path id="basicClasspath">
+ <pathelement location="../logback-core/target/classes/" />
+ <pathelement location="../logback-core/target/test-classes/" />
+ <pathelement location="./target/classes/" />
+ <pathelement location="./target/test-classes/" />
+ <pathelement location="./lib/slf4j-api-${slf4j.version}.jar" />
+ <pathelement location="./src/test/input/integration/autoInit/" />
+ </path >
+
+
+
+
+ <target name="testAll" depends="testWithoutGroovy">
+ </target>
+
+
+
+ <target name="testWithoutGroovy">
+ <junit printsummary="yes" fork="no" haltonfailure="yes">
+ <classpath refid="basicClasspath" />
+ <formatter type="plain" />
+ <test fork="yes" todir="target/unit-reports"
+ outfile="TEST-NoGroovy"
+ name="ch.qos.logback.classic.util.InitializationIntegrationTest" />
+ </junit>
+ </target>
+
+</project>
\ No newline at end of file
diff --git a/logback-classic/osgi-build.xml b/logback-classic/osgi-build.xml
index 045578f..f3586d0 100644
--- a/logback-classic/osgi-build.xml
+++ b/logback-classic/osgi-build.xml
@@ -18,28 +18,39 @@
<echo message="compile classpath: ${currentVersion}" />
<echo message="test classpath: ${test_classpath}" />
- <echo message="basedir: ${basedir}" />
+
+
<property name="iBundleJar" value="target/iBundle.jar"/>
<property name="bundlesDir" value="bundle"/>
- <!-- this is really very ugly, but it's the only way to circumvent
- http://jira.codehaus.org/browse/MANTRUN-95
- -->
- <taskdef name="junit" classpath="${test_classpath}"
- classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
+ <echo message="===============================" />
+ <echo message="basedir: ${basedir}" />
+ <echo message="===============================" />
+
+ <path id="basicCP">
+ <pathelement location="${org.apache.felix:org.apache.felix.main:jar}" />
+ <pathelement location="target/classes/" />
+ <pathelement location="target/test-classes" />
+ <!--
+ <pathelement location="${org.slf4j:slf4j-api:jar}" />
+ <pathelement location="../logback-core/target/classes/" />
+ <pathelement location="../logback-core/target/test-classes/" />
+ -->
+ </path >
+
<path id="minimal">
<pathelement location="target/test-classes/" />
</path >
<target name="copySLF4J_JAR">
- <echo>Copying ${slf4jJAR} to lib/</echo>
+ <echo>Copying ${org.slf4j:slf4j-api:jar} to lib/</echo>
<delete>
<fileset dir="../logback-examples/lib/" includes="slf4j-*SNAPSHOT.jar" />
</delete>
- <copy file="${slf4jJAR}" todir="lib/" />
+ <copy file="${org.slf4j:slf4j-api:jar}" todir="lib/" />
</target>
<target name="init" depends="copySLF4J_JAR">
@@ -80,8 +91,8 @@
<target name="logback" unless="maven.test.skip">
<prepareOSGiHarness binding="logback"/>
- <junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
- <classpath path="${test_classpath}"/>
+ <junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
+ <classpath refid="basicCP"/>
<formatter type="plain" />
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
</junit>
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 884a78a..2d0ba69 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -247,30 +247,29 @@
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.2</version>
+ <version>1.4</version>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.8.1</version>
</dependency>
<dependency>
- <groupId>ant</groupId>
- <artifactId>ant-junit</artifactId>
- <version>1.6.5</version>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
</dependency>
+
</dependencies>
+
<executions>
<execution>
<id>ant-osgi-test</id>
<phase>package</phase>
<configuration>
<tasks>
- <property name="currentVersion" value="${version}" />
+ <property name="currentVersion" value="${version}" />
<property name="slf4j.version" value="${slf4j.version}"/>
- <property name="test_classpath" refid="maven.test.classpath"/>
- <property name="slf4jJAR"
- value="${settings.localRepository}/org/slf4j/slf4j-api/${slf4j.version}/slf4j-api-${slf4j.version}.jar" />
<property name="basedir" value="${basedir}"/>
<ant antfile="${basedir}/osgi-build.xml"/>
</tasks>
@@ -280,6 +279,21 @@
</goals>
</execution>
+ <execution>
+ <id>ant-integration-test</id>
+ <phase>package</phase>
+
+
+ <configuration>
+ <tasks>
+ <property name="slf4j.version" value="${slf4j.version}"/>
+ <ant antfile="${basedir}/integration.xml"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
@@ -292,11 +306,12 @@
<reportFormat>plain</reportFormat>
<trimStackTrace>false</trimStackTrace>
<excludes>
+ <exclude>**/*.java</exclude>
<exclude>**/AllClassicTest.java</exclude>
<exclude>**/PackageTest.java</exclude>
<exclude>**/TestConstants.java</exclude>
<exclude>**/test_osgi/BundleTest.java</exclude>
-org.slf4j.test_osgi
+ <exclude>**/ch/qos/logback/classic/util/InitializationIntegrationTest.java</exclude>
<exclude>**/SerializationPerfTest.java</exclude>
</excludes>
</configuration>
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy
index f2493e7..b995c0c 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/sift/GSiftingAppender.groovy
@@ -27,7 +27,9 @@ import ch.qos.logback.core.helpers.NOPAppender
/**
* @author Ceki Gücü
*/
-class GSiftingAppender extends AppenderBase<ILoggingEvent> implements ConfigurationContributor {
+
+// The GMaven plugin does not support generics, so we use AppenderBase instead of AppenderBase<ILoggingEvent>
+class GSiftingAppender extends AppenderBase implements ConfigurationContributor {
protected AppenderTracker<ILoggingEvent> appenderTracker = new AppenderTrackerImpl<ILoggingEvent>();
@@ -87,7 +89,8 @@ class GSiftingAppender extends AppenderBase<ILoggingEvent> implements Configurat
}
@Override
- protected void append(ILoggingEvent event) {
+ public void append(Object object) {
+ ILoggingEvent event = (ILoggingEvent) object;
if (!isStarted()) {
return;
}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
index 48682da..0927830 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
@@ -65,10 +65,8 @@ public class ContextInitializer {
gafferConfigurator.run(url);
} else {
StatusManager sm = loggerContext.getStatusManager();
- if (url == null) {
- sm.add(new ErrorStatus("Groovy classes are not available on the class path. Aborting initialization.",
- loggerContext));
- }
+ sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.",
+ loggerContext));
}
}
if (url.toString().endsWith("xml")) {
diff --git a/logback-classic/src/test/input/integration/autoInit/logback.xml b/logback-classic/src/test/input/integration/autoInit/logback.xml
new file mode 100644
index 0000000..ddeb399
--- /dev/null
+++ b/logback-classic/src/test/input/integration/autoInit/logback.xml
@@ -0,0 +1,8 @@
+
+<configuration>
+
+ <appender name="LIST" class="ch.qos.logback.core.read.ListAppender"/>
+ <root level="DEBUG">
+ <appender-ref ref="LIST" />
+ </root>
+</configuration>
\ No newline at end of file
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java
similarity index 95%
rename from logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java
index b6852a7..9e76963 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/ContextInitializerTest.java
@@ -21,8 +21,6 @@ import static org.junit.Assert.assertEquals;
import java.util.List;
-import ch.qos.logback.core.util.OptionHelper;
-import ch.qos.logback.core.util.StatusPrinter;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -39,9 +37,9 @@ import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.status.StatusListener;
import ch.qos.logback.core.status.TrivialStatusListener;
-public class InitializationTest {
+public class ContextInitializerTest {
- org.slf4j.Logger logger = LoggerFactory.getLogger(InitializationTest.class);
+ org.slf4j.Logger logger = LoggerFactory.getLogger(ContextInitializerTest.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger root = (Logger) LoggerFactory.getLogger("root");
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java
new file mode 100644
index 0000000..be1d81f
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.java
@@ -0,0 +1,42 @@
+/**
+ * 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.classic.util;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.read.ListAppender;
+import ch.qos.logback.core.util.StatusPrinter;
+import org.junit.Test;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * @author Ceki Gücü
+ */
+public class InitializationIntegrationTest {
+
+
+
+ @Test
+ public void smoke() {
+ Logger logger = (Logger) LoggerFactory.getLogger(this.getClass());
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ //StatusPrinter.print((LoggerContext)LoggerFactory.getILoggerFactory());
+ ListAppender la = (ListAppender) root.getAppender("LIST");
+ assertNotNull(la);
+ }
+
+
+}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java
index 0256b5a..6d9ce5c 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/PackageTest.java
@@ -19,7 +19,7 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-(a)SuiteClasses({InitializationTest.class, LogbackMDCAdapterTest.class, LevelToSyslogSeverityTest.class} )
+(a)SuiteClasses({ContextInitializerTest.class, LogbackMDCAdapterTest.class, LevelToSyslogSeverityTest.class} )
public class PackageTest {
}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b77610a..de0b57e 100755
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,9 @@
<url>http://www.qos.ch</url>
</organization>
<inceptionYear>2005</inceptionYear>
-
+
+
+
<modules>
<module>logback-core</module>
<module>logback-classic</module>
@@ -26,11 +28,20 @@
<module>logback-examples</module>
</modules>
+ <properties>
+ <!-- slf4j.version property is used below, in
+ logback-classic/pom.xml and in setClasspath.cmd -->
+ <slf4j.version>1.6.0</slf4j.version>
+ <junit.version>4.7</junit.version>
+
+ <consolePlugin.version>1.1.0</consolePlugin.version>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
+ <version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -41,13 +52,7 @@
</dependency>
</dependencies>
- <properties>
- <!-- slf4j.version property is used below, in
- logback-classic/pom.xml and in setClasspath.cmd -->
- <slf4j.version>1.6.0</slf4j.version>
- <consolePlugin.version>1.1.0</consolePlugin.version>
- </properties>
-
+
<dependencyManagement>
<dependencies>
<!-- Project modules -->
-----------------------------------------------------------------------
Summary of changes:
logback-classic/integration.xml | 41 +++++++++++++++++++
logback-classic/osgi-build.xml | 31 ++++++++++-----
logback-classic/pom.xml | 39 +++++++++++++------
.../logback/classic/sift/GSiftingAppender.groovy | 7 ++-
.../logback/classic/util/ContextInitializer.java | 6 +--
.../test/input/integration/autoInit/logback.xml | 8 ++++
...zationTest.java => ContextInitializerTest.java} | 6 +--
.../util/InitializationIntegrationTest.java | 42 ++++++++++++++++++++
.../ch/qos/logback/classic/util/PackageTest.java | 2 +-
pom.xml | 23 +++++++----
10 files changed, 163 insertions(+), 42 deletions(-)
create mode 100644 logback-classic/integration.xml
create mode 100644 logback-classic/src/test/input/integration/autoInit/logback.xml
rename logback-classic/src/test/java/ch/qos/logback/classic/util/{InitializationTest.java => ContextInitializerTest.java} (95%)
create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationIntegrationTest.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_0.9.21-6-gc641f97
by git-noreply@pixie.qos.ch 13 Jun '10
by git-noreply@pixie.qos.ch 13 Jun '10
13 Jun '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, master has been updated
via c641f97153aecc6791e95cad237ae8706f28102e (commit)
from 521dfe290dfa34fadb247ee63607a0cddaaf181f (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=c641f97153aecc6791e95cad…
http://github.com/ceki/logback/commit/c641f97153aecc6791e95cad237ae8706f281…
commit c641f97153aecc6791e95cad237ae8706f28102e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sun Jun 13 22:38:51 2010 +0200
ongoing work on logback.groovy detection
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
index 020c97b..48682da 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
@@ -66,19 +66,17 @@ public class ContextInitializer {
} else {
StatusManager sm = loggerContext.getStatusManager();
if (url == null) {
- sm.add(new ErrorStatus("Groovy classes are not available on the class path]",
+ sm.add(new ErrorStatus("Groovy classes are not available on the class path. Aborting initialization.",
loggerContext));
}
}
-
-
- if (url.toString().endsWith("xml")) {
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(loggerContext);
- configurator.doConfigure(url);
- }
-
}
+ if (url.toString().endsWith("xml")) {
+ JoranConfigurator configurator = new JoranConfigurator();
+ configurator.setContext(loggerContext);
+ configurator.doConfigure(url);
+ }
+ }
void joranConfigureByResource(URL url) throws JoranException {
JoranConfigurator configurator = new JoranConfigurator();
@@ -88,7 +86,6 @@ public class ContextInitializer {
private URL findConfigFileURLFromSystemProperties(ClassLoader classLoader, boolean updateStatus) {
String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
-
if (logbackConfigFile != null) {
URL result = null;
try {
@@ -139,9 +136,9 @@ public class ContextInitializer {
}
private URL getResource(String filename, ClassLoader myClassLoader, boolean updateStatus) {
- URL url = Loader.getResource(GROOVY_AUTOCONFIG_FILE, myClassLoader);
+ URL url = Loader.getResource(filename, myClassLoader);
if (updateStatus) {
- statusOnResourceSearch(GROOVY_AUTOCONFIG_FILE, myClassLoader, url);
+ statusOnResourceSearch(filename, myClassLoader, url);
}
return url;
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
index 519c1eb..b6852a7 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import java.util.List;
+import ch.qos.logback.core.util.OptionHelper;
+import ch.qos.logback.core.util.StatusPrinter;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
-----------------------------------------------------------------------
Summary of changes:
.../logback/classic/util/ContextInitializer.java | 21 ++++++++-----------
.../logback/classic/util/InitializationTest.java | 2 +
2 files changed, 11 insertions(+), 12 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[JIRA] Created: (LBCORE-156) 3 similar errors Share this error Delete this error Error Message java.lang.NoClassDefFoundError: ch/qos/logback/core/recovery/RecoveryCoordinator
by Benjamin Darfler (JIRA) 11 Jun '10
by Benjamin Darfler (JIRA) 11 Jun '10
11 Jun '10
3 similar errors Share this error Delete this error Error Message java.lang.NoClassDefFoundError: ch/qos/logback/core/recovery/RecoveryCoordinator
----------------------------------------------------------------------------------------------------------------------------------------------------
Key: LBCORE-156
URL: http://jira.qos.ch/browse/LBCORE-156
Project: logback-core
Issue Type: Bug
Environment: Logback-Classic 0.9.20 SLF4J 1.5.11
Reporter: Benjamin Darfler
Assignee: Logback dev list
Error Message
java.lang.NoClassDefFoundError: ch/qos/logback/core/recovery/RecoveryCoordinator
Stack Trace
ch.qos.logback.core.recovery.ResilientOutputStreamBase.postIOFailure(ResilientOutputStreamBase.java:105)
ch.qos.logback.core.recovery.ResilientOutputStreamBase.write(ResilientOutputStreamBase.java:55)
java.io.OutputStream.write(OutputStream.java:58)
ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(LayoutWrappingEncoder.java:103)
ch.qos.logback.core.OutputStreamAppender.writeOut(OutputStreamAppender.java:193)
ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:220)
ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:216)
ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:148)
ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:108)
ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:91)
ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:64)
ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:275)
ch.qos.logback.classic.Logger.callAppenders(Logger.java:262)
ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:465)
ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:419)
ch.qos.logback.classic.Logger.info(Logger.java:635)
com.locamoda.service.user.UserNameHandler.updateIfNecessary(UserNameHandler.java:121)
com.locamoda.service.user.UserNameHandler.onHttpRequest(UserNameHandler.java:76)
sun.reflect.GeneratedMethodAccessor1325.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:168)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1987)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:619)
--
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
3
2