Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF29EE265 for ; Wed, 26 Dec 2012 19:50:30 +0000 (UTC) Received: (qmail 9045 invoked by uid 500); 26 Dec 2012 19:50:30 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 9022 invoked by uid 500); 26 Dec 2012 19:50:30 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 9015 invoked by uid 99); 26 Dec 2012 19:50:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Dec 2012 19:50:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Dec 2012 19:50:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1C57023888D2; Wed, 26 Dec 2012 19:50:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@logging.apache.org From: rgoers@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121226195006.1C57023888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + Add SMTPAppender. + PatternLayout should format throwables without requiring a converter. 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 @@ + 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 @@ ]]>

+ + +

+ Sends an e-mail when a specific logging event occurs, typically on errors or fatal errors. +

+

+ The number of logging events delivered in this e-mail depend on the value of + BufferSize option. The SMTPAppender keeps only the last + BufferSize logging events in its cyclic buffer. This keeps + memory requirements at a reasonable level while still delivering useful + application context. +

+

+ 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. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter NameTypeDescription
bccStringThe comma-separated list of BCC email addresses.
ccStringThe comma-separated list of CC email addresses.
bufferSizeintegerThe maximum number of log events to be buffered for inclusion in the message. Defaults to 512.
filterFilterA Filter to determine if the event should be handled by this Appender. More than one Filter + may be used by using a CompositeFilter. +
fromStringThe email address of the sender.
layoutLayoutThe Layout to use to format the LogEvent. The default is SerializedLayout.
nameStringThe name of the Appender.
replyToStringThe comma-separated list of reply-to email addresses.
smtpDebugbooleanWhen set to true enables session debugging on STDOUT. Defaults to false.
smtpHostStringThe SMTP hostname to send to. This parameter is required.
smtpPasswordStringThe password required to authenticate against the SMTP server.
smtpPortintegerThe SMTP port to send to.
smtpProtocolStringThe SMTP transport protocol (such as "smtps", defaults to "smtp").
smtpUsernameStringThe username required to authenticate against the SMTP server.
suppressExceptionsbooleanThe default is true, causing exceptions to be internally logged and then ignored. When set to + false exceptions will be percolated to the caller. +
toStringThe comma-separated list of recipient email addresses.
SMTPAppender Parameters
+

+
+  
+    
+    
+  
+  
+    
+      
+    
+  
+]]>
+