logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1426001 [2/2] - in /logging/log4j/log4j2/trunk: ./ core/ core/src/main/java/org/apache/logging/log4j/core/ core/src/main/java/org/apache/logging/log4j/core/appender/ core/src/main/java/org/apache/logging/log4j/core/helpers/ core/src/main/j...
Date Wed, 26 Dec 2012 19:50:04 GMT
Modified: logging/log4j/log4j2/trunk/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java?rev=1426001&r1=1426000&r2=1426001&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
Wed Dec 26 19:50:03 2012
@@ -19,6 +19,7 @@ package org.apache.logging.slf4j;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.Appender;
 import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.helpers.Constants;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
@@ -51,8 +52,6 @@ import static org.junit.Assert.assertTru
  */
 public class LoggerTest {
 
-    private static final String LINE_SEP = System.getProperty("line.separator");
-    
     private static final String CONFIG = "log4j-test1.xml";
     private static LoggerContext ctx;
 
@@ -76,23 +75,23 @@ public class LoggerTest {
     @Test
     public void basicFlow() {
         xlogger.entry();
-        verify("List", "o.a.l.s.LoggerTest entry MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest entry MDC{}" + Constants.LINE_SEP);
         xlogger.exit();
-        verify("List", "o.a.l.s.LoggerTest exit MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest exit MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
     public void simpleFlow() {
         xlogger.entry(CONFIG);
-        verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest entry with (log4j-test1.xml) MDC{}" + Constants.LINE_SEP);
         xlogger.exit(0);
-        verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest exit with (0) MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
     public void throwing() {
         xlogger.throwing(new IllegalArgumentException("Test Exception"));
-        verify("List", "o.a.l.s.LoggerTest throwing MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest throwing MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
@@ -101,32 +100,32 @@ public class LoggerTest {
             throw new NullPointerException();
         } catch (final Exception e) {
             xlogger.catching(e);
-            verify("List", "o.a.l.s.LoggerTest catching MDC{}" + LINE_SEP);
+            verify("List", "o.a.l.s.LoggerTest catching MDC{}" + Constants.LINE_SEP);
         }
     }
 
     @Test
     public void debug() {
         logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
     public void debugNoParms() {
         logger.debug("Debug message {}");
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEP);
         logger.debug("Debug message {}", (Object[]) null);
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEP);
         ((LocationAwareLogger)logger).log(null, SLF4JLogger.class.getName(), LocationAwareLogger.DEBUG_INT,
             "Debug message {}", null, null);
-        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Constants.LINE_SEP);
     }
 
 
     @Test
     public void debugWithParms() {
         logger.debug("Hello, {}", "World");
-        verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Hello, World MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
@@ -134,10 +133,10 @@ public class LoggerTest {
 
         MDC.put("TestYear", "2010");
         logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Constants.LINE_SEP);
         MDC.clear();
         logger.debug("Debug message");
-        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
@@ -150,9 +149,9 @@ public class LoggerTest {
     @Test
     public void doubleSubst() {
         logger.debug("Hello, {}", "Log4j {}");
-        verify("List", "o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Hello, Log4j {} MDC{}" + Constants.LINE_SEP);
         xlogger.debug("Hello, {}", "Log4j {}");
-        verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + LINE_SEP);
+        verify("List", "o.a.l.s.LoggerTest Hello, Log4j Log4j {} MDC{}" + Constants.LINE_SEP);
     }
 
     @Test
@@ -169,7 +168,7 @@ public class LoggerTest {
         data.put("Amount", "200.00");
         EventLogger.logEvent(data);
         MDC.clear();
-        verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\"
FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + LINE_SEP);
+        verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\"
FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Constants.LINE_SEP);
     }
 
     private void verify(final String name, final String expected) {

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1426001&r1=1426000&r2=1426001&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed Dec 26 19:50:03 2012
@@ -23,6 +23,9 @@
 
   <body>
     <release version="2.0-beta4" date="TBD" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-131" dev="rgoers" type="add" due-to="Scott Severtson">
+        Add SMTPAppender.
+      </action>
       <action issue="LOG4J2-130" dev="rgoers" type="fix">
         PatternLayout should format throwables without requiring a converter.
       </action>

Modified: logging/log4j/log4j2/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/site.xml?rev=1426001&r1=1426000&r2=1426001&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/site.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/site.xml Wed Dec 26 19:50:03 2012
@@ -74,6 +74,7 @@
         <item name="Rewrite" href="/manual/appenders.html#RewriteAppender"/>
         <item name="RollingFile" href="/manual/appenders.html#RollingFileAppender"/>
         <item name="Routing" href="/manual/appenders.html#RoutingAppender"/>
+        <item name="SMTP" href="/manual/appenders.html#SMTPAppender"/>
         <item name="Socket" href="/manual/appenders.html#SocketAppender"/>
         <item name="Syslog" href="/manual/appenders.html#SyslogAppender"/>
       </item>

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml?rev=1426001&r1=1426000&r2=1426001&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml Wed Dec 26 19:50:03 2012
@@ -1406,6 +1406,131 @@
 </configuration>]]></pre>
           </p>
         </subsection>
+        <a name="SMTPAppender"/>
+        <subsection name="SMTPAppender">
+          <p>
+            Sends an e-mail when a specific logging event occurs, typically on errors or
fatal errors.
+          </p>
+          <p>
+            The number of logging events delivered in this e-mail depend on the value of
+            <b>BufferSize</b> option. The <code>SMTPAppender</code>
keeps only the last
+            <code>BufferSize</code> logging events in its cyclic buffer. This
keeps
+            memory requirements at a reasonable level while still delivering useful
+            application context.
+          </p>
+          <p>
+            The default behavior is to trigger sending an email whenever an ERROR or higher
+            severity event is logged and to format it as HTML. The circumstances on when
the
+            email is sent can be controlled by setting one or more filters on the Appender.
+            As with other Appenders, the formatting can be controlled by specifying a Layout
+            for the Appender.
+          </p>
+          <table>
+            <tr>
+              <th>Parameter Name</th>
+              <th>Type</th>
+              <th>Description</th>
+            </tr>
+            <tr>
+              <td>bcc</td>
+              <td>String</td>
+              <td>The comma-separated list of BCC email addresses.</td>
+            </tr>
+            <tr>
+              <td>cc</td>
+              <td>String</td>
+              <td>The comma-separated list of CC email addresses.</td>
+            </tr>
+            <tr>
+              <td>bufferSize</td>
+              <td>integer</td>
+              <td>The maximum number of log events to be buffered for inclusion in
the message. Defaults to 512.</td>
+            </tr>
+            <tr>
+              <td>filter</td>
+              <td>Filter</td>
+              <td>A Filter to determine if the event should be handled by this Appender.
More than one Filter
+                may be used by using a CompositeFilter.
+              </td>
+            </tr>
+            <tr>
+              <td>from</td>
+              <td>String</td>
+              <td>The email address of the sender.</td>
+            </tr>
+            <tr>
+              <td>layout</td>
+              <td>Layout</td>
+              <td>The Layout to use to format the LogEvent. The default is SerializedLayout.</td>
+            </tr>
+            <tr>
+              <td>name</td>
+              <td>String</td>
+              <td>The name of the Appender.</td>
+            </tr>
+            <tr>
+              <td>replyTo</td>
+              <td>String</td>
+              <td>The comma-separated list of reply-to email addresses.</td>
+            </tr>
+            <tr>
+              <td>smtpDebug</td>
+              <td>boolean</td>
+              <td>When set to true enables session debugging on STDOUT. Defaults to
false.</td>
+            </tr>
+            <tr>
+              <td>smtpHost</td>
+              <td>String</td>
+              <td>The SMTP hostname to send to. This parameter is required.</td>
+            </tr>
+            <tr>
+              <td>smtpPassword</td>
+              <td>String</td>
+              <td>The password required to authenticate against the SMTP server.</td>
+            </tr>
+            <tr>
+              <td>smtpPort</td>
+              <td>integer</td>
+              <td>The SMTP port to send to. </td>
+            </tr>
+            <tr>
+              <td>smtpProtocol</td>
+              <td>String</td>
+              <td>The SMTP transport protocol (such as "smtps", defaults to "smtp").</td>
+            </tr>
+            <tr>
+              <td>smtpUsername</td>
+              <td>String</td>
+              <td>The username required to authenticate against the SMTP server.</td>
+            </tr>
+            <tr>
+              <td>suppressExceptions</td>
+              <td>boolean</td>
+              <td>The default is true, causing exceptions to be internally logged and
then ignored. When set to
+                false exceptions will be percolated to the caller.
+              </td>
+            </tr>
+            <tr>
+              <td>to</td>
+              <td>String</td>
+              <td>The comma-separated list of recipient email addresses.</td>
+            </tr>
+            <caption align="top">SMTPAppender Parameters</caption>
+          </table>
+          <pre class="prettyprint linenums"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<configuration status="warn" name="MyApp" packages="">
+  <appenders>
+    <SMTP name="Mail" suppressExceptions="false" subject="Error Log" to="errors@logging.apache.org"
+      from="test@logging.apache.org" smtpHost="localhost" smtpPort="25" bufferSize="50">
+    </SMTP>
+  </appenders>
+  <loggers>
+    <root level="error">
+      <appender-ref ref="Mail"/>
+    </root>
+  </loggers>
+</configuration>]]></pre>
+        </subsection>
         <a name="SocketAppender"/>
         <subsection name="SocketAppender">
           <p>



Mime
View raw message