[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.25-24-gea89ebf

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Nov 8 18:57:16 CET 2010


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  ea89ebffd3a509b2e34e234eaf4625bd32d47042 (commit)
      from  b9fb42f9775dacaba995d2fb94b31753e0cbdb63 (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=ea89ebffd3a509b2e34e234eaf4625bd32d47042
http://github.com/ceki/logback/commit/ea89ebffd3a509b2e34e234eaf4625bd32d47042

commit ea89ebffd3a509b2e34e234eaf4625bd32d47042
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Nov 8 18:56:02 2010 +0100

    ongoing work on the docs

diff --git a/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java b/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java
index bf7f44c..c07f3cd 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java
+++ b/logback-examples/src/main/java/chapters/appenders/mail/Marked_EMail.java
@@ -52,8 +52,8 @@ public class Marked_EMail {
       }
     }
 
-    Marker notifyAdminMarker = MarkerFactory.getMarker("NOTIFY_ADMIN");
-    logger.error(notifyAdminMarker,
+    Marker notifyAdmin = MarkerFactory.getMarker("NOTIFY_ADMIN");
+    logger.error(notifyAdmin,
         "This is a serious an error requiring the admin's attention",
         new Exception("Just testing"));
 
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mail1.xml b/logback-examples/src/main/java/chapters/appenders/mail/mail1.xml
index dd162cc..2ad7810 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail1.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail1.xml
@@ -5,7 +5,7 @@
     <To>EMAIL-DESTINATION</To>
     <To>ANOTHER_EMAIL_DESTINATION</To> <!-- additional destinations are possible -->
     <From>SENDER-EMAIL</From>
-    <Subject>TESTING: %logger{20} - %m</Subject>
+    <Subject>%logger{20} - %m</Subject>
     <layout class="ch.qos.logback.classic.PatternLayout">
       <Pattern>%date %-5level %logger - %message%n</Pattern>
     </layout>	    
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mail2.xml b/logback-examples/src/main/java/chapters/appenders/mail/mail2.xml
index 2754181..e9ecdba 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail2.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail2.xml
@@ -6,7 +6,8 @@
     <SMTPHost>${smtpHost}</SMTPHost>
     <To>${to}</To>
     <From>${from}</From>
-    <layout class="ch.qos.logback.classic.html.HTMLLayout"/>
+    <Subject>%logger{20} - %m</Subject>
+    <Layout class="ch.qos.logback.classic.html.HTMLLayout"/>
   </appender>
 
   <root level="debug">
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 01b1832..78004da 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
@@ -11,6 +11,7 @@
     <SMTPHost>${smtpHost}</SMTPHost>
     <To>${to}</To>
     <From>${from}</From>
+    <subject>%logger{20} - %m</subject>
     <layout class="ch.qos.logback.classic.html.HTMLLayout"/>
   </appender>
 
diff --git a/logback-site/src/site/pages/documentation.html b/logback-site/src/site/pages/documentation.html
index 3282dc5..841ac67 100644
--- a/logback-site/src/site/pages/documentation.html
+++ b/logback-site/src/site/pages/documentation.html
@@ -36,7 +36,7 @@
 				and Tomcat</a>
 			</li>
 
-      <li><a href="recipes/index.html">The logback recipes</a></li>
+      <li><a href="recipes/index.html">Real-world inspired recipes</a></li>
 
       <li>
       	<a href="faq.html">A Frequently Asked Questions list (FAQ)</a>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 7e6c34c..af61cde 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -2479,7 +2479,7 @@ Context ctx = new InitialContext(env);</pre>
     &lt;SMTPHost>${smtpHost}&lt;/SMTPHost>
     &lt;To>${to}&lt;/To>
     &lt;From>${from}&lt;/From>
-    &lt;Subject>TESTING: %logger{20} - %m&lt;/Subject>
+    &lt;Subject>%logger{20} - %m&lt;/Subject>
     &lt;Layout class="ch.qos.logback.classic.html.HTMLLayout"/>
 
     <b>&lt;CyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTrackerImpl"></b>
@@ -2579,6 +2579,8 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
     &lt;SMTPHost>${smtpHost}&lt;/SMTPHost>
     &lt;To>${to}&lt;/To>
     &lt;From>${from}&lt;/From>
+    &lt;Subject>%logger{20} - %m&lt;/Subject>
+
     &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"/>
   &lt;/appender>
 
@@ -2592,30 +2594,31 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
     based triggering</a> 
     </h3>
 
-    <p>Although reasonable, a policy whereby event's of level ERROR
-    trigger an outgoing email may result in too many emails,
-    cluttering the targeted user's mailbox. Logback ships with another
-    triggering policy, called <a
+    <p>Although reasonable the default triggering policy whereby every
+    event of level ERROR triggers an outgoing email may result in too
+    many emails, cluttering the targeted user's mailbox. Logback ships
+    with another triggering policy, called <a
     href="../xref/ch/qos/logback/classic/boolex/OnMarkerEvaluator.html">OnMarkerEvaluator</a>. It
-    is based on markers allowing for a very effective way for trigger
-    control. In essence, emails are triggered only if the event is
-    marked with a user-specified marker. An example should make the
-    point clearer.
+    is based on markers. In essence, emails are triggered only if the
+    event is marked with a user-specified marker. The next example
+    should make the point clearer.
     </p>
 
-    <p>The <a href="../xref/chapters/appenders/mail/Marked_EMail.html">Marked_EMail</a> application contains several logging
-    statements some of which are of level ERROR. One noteworthy
-    statement contains  a marker. Here is the relevant code.
+    <p>The <a
+    href="../xref/chapters/appenders/mail/Marked_EMail.html">Marked_EMail</a>
+    application contains several logging statements some of which are
+    of level ERROR. One noteworthy statement contains a marker. Here
+    is the relevant code.
     </p>
 
-    <pre class="prettyprint source">Marker notifyAdminMarker = MarkerFactory.getMarker("NOTIFY_ADMIN");
-logger.error(<b>notifyAdminMarker</b>,
+    <pre class="prettyprint source">Marker notifyAdmin = MarkerFactory.getMarker("NOTIFY_ADMIN");
+logger.error(<b>notifyAdmin</b>,
   "This is a serious an error requiring the admin's attention",
    new Exception("Just testing"));</pre>
 
-   <p>The next configuration file will cause outgoing emails to be
-   sent only in presence of events bearing the NOTIFY_ADMIN or the
-   TRANSACTION_FAILURE marker.
+   <p>The next configuration file will trigger outgoing emails only in
+   presence of events bearing the NOTIFY_ADMIN or the
+   TRANSACTION_FAILURE markers.
    </p>
 
    <p class="example">Example: <code>SMTPAppender</code> with 
@@ -2647,15 +2650,19 @@ logger.error(<b>notifyAdminMarker</b>,
   chapters.appenders.mail.Marked_EMail src/main/java/chapters/appenders/mail/mailWithMarker.xml</pre>
 
 
+  <h4><a name="marker_JaninoEventEvaluator"
+    href="#marker_GEventEvaluator">Marker-based triggering with
+    JaninoEventEvaluator</a></h4>
+
     <p>Note that instead of using the marker-centric
-    OnMarkerEvaluator, we could use the much more generic <a
+    <code>OnMarkerEvaluator</code>, we could use the much more generic
+    <a
     href="filters.html#JaninoEventEvaluator"><code>JaninoEventEvaluator</code></a>
     or its even more powerful cousin <a
     href="filters.html#GEventEvaluator"><code>GEventEvaluator</code></a>.
-    </p>
-
-    <p>The following configuration file uses JaninoEventEvaluator
-    instead of OnMarkerEvaluator but is otherwise equivalent to the
+    For example, the following configuration file uses
+    <code>JaninoEventEvaluator</code> instead of
+    <code>OnMarkerEvaluator</code> but is otherwise equivalent to the
     previous configuration file.
     </p>
 
@@ -2675,6 +2682,9 @@ logger.error(<b>notifyAdminMarker</b>,
   &lt;/appender>
 &lt;/configuration></pre>
 
+    <h4><a name="marker_GEventEvaluator"
+    href="#marker_GEventEvaluator">Marker-based triggering with
+    GEventEvaluator</a></h4>
     <p>Here is the equivalent evaluator using <a
     href="filters.html#GEventEvaluator">GEventEvaluator</a>.</p>
 
diff --git a/logback-site/src/site/pages/recipes/emailPerTransaction.html b/logback-site/src/site/pages/recipes/emailPerTransaction.html
index edb62c0..05aa27b 100644
--- a/logback-site/src/site/pages/recipes/emailPerTransaction.html
+++ b/logback-site/src/site/pages/recipes/emailPerTransaction.html
@@ -21,7 +21,8 @@
     </div>
     <div id="content">
       
-      <h2>Send an email per transaction but only for certain users</h2>
+      <h2>Triggering an email containing the isoloated logs of selected
+      transactions</h2>
       
       <p>Let Dave and Tata be software engineers working at a company
       called Fooware.com. As you might have guessed, Fooware.com sells
@@ -35,44 +36,98 @@
       logging data generated by Buscrit as conveniently as
       possible. Tata could access the log files directly on the server
       where Buscrit runs. Let us assume that accessing the log files
-      is impractical because one of the following conditions holds
-      true:
+      is impractical because one or ore more of the following
+      conditions holds true:
       </p>
 
       <ol>
-        <li>Buscrit runs on several hosts and it is difficult to
+        <li>Buscrit runs on multiple hosts and it is difficult to
         identify the host where a particular transaction was
         executed</li>
         <li>Tata does not (or does not wish to) have access to the
         hosts where Byscrit runs
         </li>
-        <li>Buscrit is tested by half a dozen testers simultanesouly
-        so that it is hard to indetify and track an individual
+        <li>Buscrit is tested by multiple testers simultanesouly so
+        that it is hard to indetify and track an individual
         transaction in the log files
         </li>
       </ol>
 
       <p>Given the above circumstances, let us create a logback
-      configuration so that Tata receives an email message containing
-      the logs generated by a single transaction. We will later refine
-      this configuration so that Tata will receive an email per transaction
-      but only for the transactions she explicitly selects.
+      configuration so that Tata receives an email message at the end
+      of every transaction. We will iteratively refine this
+      configuration so that Tata will receive an email containing the
+      logs of each transaction in isolation and only for the
+      transactions she explicitly selects.
       </p>
 
-      <h3>Generating an email message containing the logs of a single
-      transaction
-      </h3>
+      <h3>Triggering an email message at the end of each transaction</h3>
 
       <p>We will be using <code>SMTPAppender</code> to generate emails
       containing logging data. Please refer to the <a
       href="../manual/appenders.html#SMTPAppender">appropriate section
       of the manual</a> to familiarize yourself with
-      <code>SMTPAppender</code>.
-
-is described in chapter on
-      appenders describes <pre class="prettyprint
-      source">&lt;configuration scan="true" scanPeriod="3 seconds">
+      <code>SMTPAppender</code> and its properties.
+      </p>
 
+      <p>The logback-demo project ships with a Struts action, namely
+      PrimeAction, which can factorize integers. Here is the pertinent
+      structure of the code:</p>
+
+      <pre class="prettyprint source">package ch.qos.logback.demo.prime;
+
+import org.apache.struts.action.Action;
+...
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class PrimeAction extends Action {
+
+  Logger logger = LoggerFactory.getLogger(PrimeAction.class);
+  Marker SMTP_TRIGGER = MarkerFactory.getMarker("SMTP_TRIGGER");
+
+  public ActionForward execute(ActionMapping actionMapping,
+                               ActionForm actionForm, HttpServletRequest request,
+                               HttpServletResponse response) throws Exception {
+
+    PrimeForm form = (PrimeForm) actionForm;
+
+    Long number = form.getNumber();
+    try {
+      NumberCruncher nc = new NumberCruncherImpl();
+      Long start = System.currentTimeMillis();
+      Long[] result = nc.factor(number);
+      Long duration = System.currentTimeMillis() - start;
+      logger.info("Results computed in {} ms", duration);
+
+      ...
+    } finally {
+      <b>logger.info(SMTP_TRIGGER, "Prime computation ended");</b>
+    }
+  }
+} </pre>
+
+      <p>In a real world application, a transaction would involve
+      systems external to the application, e.g. a database or a
+      messaging queue. For the sake of simplicity, let us consider
+      each factorization request as a <em>transaciton</em>.  At the
+      end of each factorization request, i.e. each transaction, the
+      logger of the <code>PrimeAction</code> instance is invoked with
+      the SMTP_TRIGGER marker and the message "Prime computation
+      ended". Thus, we can capitalize on this logging request to
+      clarly identify the end of every transaction in order to trigger
+      an outgoing message.
+     </p>
+
+     <p>Here is a configuration file which uses JaninoEventEvaluator
+     to trigger an outgoing email for logging event marked with
+     SMTP_TRIGGER.
+     </p>
+
+    <pre class="prettyprint
+     source">&lt;configuration scan="true" scanPeriod="3 seconds">
+
+  &lt;!-- always a good idea to have an OnConsoleStatusListener -->
   &lt;statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
 
   &lt;appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
@@ -82,11 +137,12 @@ is described in chapter on
     &lt;layout class="ch.qos.logback.classic.html.HTMLLayout">
       &lt;pattern>%date%level%logger{24}%msg&lt;/pattern>
     &lt;/layout>
-    &lt;evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
-      &lt;expression>
-        marker != null  &amp;&amp; marker.contains("SMTP_TRIGGER") 
-      &lt;/expression>
-    &lt;/evaluator>    
+    
+    <b>&lt;evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"></b>
+      <b>&lt;expression></b>
+        <b>marker != null  &amp;&amp; marker.contains("SMTP_TRIGGER")</b>
+      <b>&lt;/expression></b>
+    <b>&lt;/evaluator></b>
   &lt;/appender>
 
   &lt;root level="DEBUG">
@@ -95,8 +151,50 @@ is described in chapter on
 
 &lt;/configuration></pre>
       
-  <pre>
- &lt;appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
+      <h3>Transaction isolation</h3>
+
+
+
+
+  <pre class="prettyprint source">&lt;configuration scan="true" scanPeriod="3 seconds">
+
+  &lt;!-- always a good idea to have an OnConsoleStatusListener -->
+
+  &lt;appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
+    &lt;SMTPHost>NAME_OF_SMTP_HOST&lt;/SMTPHost>
+    &lt;To>com&lt;/To>
+    &lt;From>&lt;/From>
+    &lt;layout class="ch.qos.logback.classic.html.HTMLLayout">
+       &lt;pattern>%date%level%logger{24}%msg&lt;/pattern>
+    &lt;/layout>
+
+    &lt;discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
+      &lt;key>uuid&lt;/key>
+      &lt;defaultValue>default&lt;/defaultValue>
+    &lt;/discriminator>
+
+    &lt;evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator">
+      &lt;expression>
+        marker != null &amp;&amp; marker.contains("SMTP_TRIGGER") 
+      &lt;/expression>
+    &lt;/evaluator>
+
+    &lt;discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
+      &lt;key>uuid&lt;/key>
+      &lt;defaultValue>default&lt;/defaultValue>
+    &lt;/discriminator>
+
+  &lt;/appender>  </pre>
+      
+
+  <h3>Selective triggering &amp; Transaction isolation</h3>
+      
+
+  <pre class="prettyprint source">&lt;configuration scan="true" scanPeriod="3 seconds">
+
+  &lt;!-- always a good idea to have an OnConsoleStatusListener -->
+
+  &lt;appender name="SMTP" class="ch.qos.logback.classic.net.SMTPAppender">
     &lt;SMTPHost>NAME_OF_SMTP_HOST&lt;/SMTPHost>
     &lt;To>com&lt;/To>
     &lt;From>&lt;/From>
@@ -123,8 +221,7 @@ is described in chapter on
       &lt;defaultValue>default&lt;/defaultValue>
     &lt;/discriminator>
 
-  &lt;/appender>
-  </pre>
+  &lt;/appender>  </pre>
       <script src="../templates/footer.js" type="text/javascript"></script>	
     </div>
   </body>
diff --git a/logback-site/src/site/pages/recipes/index.html b/logback-site/src/site/pages/recipes/index.html
index 6b130e0..d2d24d5 100644
--- a/logback-site/src/site/pages/recipes/index.html
+++ b/logback-site/src/site/pages/recipes/index.html
@@ -19,11 +19,11 @@
     </div>
     <div id="content">
       
-      <h2>Logback recipes</h2>
+      <h2>Real-world inspired logback recipes</h2>
       
       <div>
-        <p>Here is a list of logback-related recipes which you may
-        fund useful.</p>
+        <p>Here is a list of logback-related recipes inpired by
+        real-world use cases:</p>
 
         <ul>
           <li><p><a href="emailPerTransaction.html">send an email per

-----------------------------------------------------------------------

Summary of changes:
 .../java/chapters/appenders/mail/Marked_EMail.java |    4 +-
 .../main/java/chapters/appenders/mail/mail1.xml    |    2 +-
 .../main/java/chapters/appenders/mail/mail2.xml    |    3 +-
 .../main/java/chapters/appenders/mail/mail3.xml    |    1 +
 logback-site/src/site/pages/documentation.html     |    2 +-
 logback-site/src/site/pages/manual/appenders.html  |   54 ++++---
 .../site/pages/recipes/emailPerTransaction.html    |  151 ++++++++++++++++----
 logback-site/src/site/pages/recipes/index.html     |    6 +-
 8 files changed, 166 insertions(+), 57 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list