
Author: ceki Date: Thu Aug 28 09:43:26 2008 New Revision: 1784 Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java logback/trunk/logback-examples/src/main/java/chapter4/mail/EMail.java logback/trunk/logback-examples/src/main/java/chapter4/mail/mail1.xml logback/trunk/logback-examples/src/main/java/chapter4/mail/mail2.xml logback/trunk/logback-site/src/site/pages/manual/appenders.html logback/trunk/logback-site/src/site/pages/manual/index_menu.js logback/trunk/logback-site/src/site/pages/news.html Log: - minor corrections and improvements Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java ============================================================================== --- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java (original) +++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java Thu Aug 28 09:43:26 2008 @@ -31,7 +31,7 @@ */ public class SMTPAppender extends SMTPAppenderBase<LoggingEvent> { - static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m %nopex"; + static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m"; static final String DEFAULT_EVALUATOR_EXPRESSION = "level >= ERROR"; private int bufferSize = 512; Modified: logback/trunk/logback-examples/src/main/java/chapter4/mail/EMail.java ============================================================================== --- logback/trunk/logback-examples/src/main/java/chapter4/mail/EMail.java (original) +++ logback/trunk/logback-examples/src/main/java/chapter4/mail/EMail.java Thu Aug 28 09:43:26 2008 @@ -33,15 +33,13 @@ int runLength = Integer.parseInt(args[0]); String configFile = args[1]; - if (configFile.endsWith(".xml")) { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - JoranConfigurator configurator = new JoranConfigurator(); - lc.shutdownAndReset(); - configurator.setContext(lc); - configurator.doConfigure(configFile); - StatusPrinter.print(lc); - } - + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + JoranConfigurator configurator = new JoranConfigurator(); + lc.shutdownAndReset(); + configurator.setContext(lc); + configurator.doConfigure(configFile); + StatusPrinter.printIfErrorsOccured(lc); + Logger logger = LoggerFactory.getLogger(EMail.class); for (int i = 1; i <= runLength; i++) { @@ -53,6 +51,8 @@ } logger.error("At last an error.", new Exception("Just testing")); + + StatusPrinter.printIfErrorsOccured(lc); } static void usage(String msg) { Modified: logback/trunk/logback-examples/src/main/java/chapter4/mail/mail1.xml ============================================================================== --- logback/trunk/logback-examples/src/main/java/chapter4/mail/mail1.xml (original) +++ logback/trunk/logback-examples/src/main/java/chapter4/mail/mail1.xml Thu Aug 28 09:43:26 2008 @@ -1,15 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> -<!-- ========================================================== --> -<!-- Sample SMTPAppender configuration using the PatternLayout --> -<!-- ========================================================== --> - <configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost> - <To>DESTINATION-EMAIL</To> + <To>EMAIL-DESTINATION</To> + <To>ANOTHER_EMAIL_DESTINATION</To> <!-- a second destination is optional --> <From>SENDER-EMAIL</From> + <Subject>TESTING: %logger{20} - %m</Subject> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%date %-5level %logger - %message%n</Pattern> </layout> Modified: logback/trunk/logback-examples/src/main/java/chapter4/mail/mail2.xml ============================================================================== --- logback/trunk/logback-examples/src/main/java/chapter4/mail/mail2.xml (original) +++ logback/trunk/logback-examples/src/main/java/chapter4/mail/mail2.xml Thu Aug 28 09:43:26 2008 @@ -1,9 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<!-- ======================================================= --> -<!-- Sample SMTPAppender configuration using the HTMLLayout --> -<!-- ======================================================= --> - <configuration> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> Modified: logback/trunk/logback-site/src/site/pages/manual/appenders.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/appenders.html (original) +++ logback/trunk/logback-site/src/site/pages/manual/appenders.html Thu Aug 28 09:43:26 2008 @@ -1888,16 +1888,16 @@ <a name="SMTPAppender"/> <h3>SMTPAppender</h3> - <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 when a - user specified event occurs. - By default, the email is sent as the reception of an event - of level <em>ERROR</em> or higher. + <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 when a user-specified event occurs. By default, the + sending of such email is triggered by an event of level ERROR or + higher. </p> - <p> - The various options for <code>SMTPAppender</code> are summarized in the following table. + <p>The various options for <code>SMTPAppender</code> are + summarized in the following table. </p> <table class="bodyTable"> @@ -1987,35 +1987,42 @@ </tr> </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. - 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 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. + 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> + + <p>The <code>SMTPAppender</code> relies on the JavaMail API. It + has been tested with JavaMail API version 1.4. The JavaMail API + requires the JavaBeans Activation Framework package. You can + download the <a + href="http://java.sun.com/products/javamail/">JavaMail API</a> and + the <a + href="http://java.sun.com/beans/glasgow/jaf.html">Java-Beans + Activation Framework</a> from their respective websites. Make + sure to place these two jar files in the classpath before trying + the following examples. </p> - <p> - The <code>SMTPAppender</code> relies on the JavaMail API. - It has been tested with JavaMail API version 1.4. - The JavaMail API requires the JavaBeans Activation Framework package. - You can download the <a href="http://java.sun.com/products/javamail/">JavaMail API</a> - and the <a href="http://java.sun.com/beans/glasgow/jaf.html">Java-Beans Activation Framework</a> - from their respective websites. - Make sure to place these two jar files in the classpath before - trying the following examples. - </p> - - <p> - A sample application called <code>chapter4.mail.EMail</code> takes two parameters. - The first parameter is an integer corresponding to the number of logging events - to generate. The second parameter is the logback configuration file in XML format. - The last logging event generated by chapter4.mail.Email application is always an - <em>ERROR</em> event which triggers the transmission of an email message. + + <p>A sample application, <a + href="../xref/chapter4/mail/EMail.html"><code>chapter4.mail.EMail</code></a> + generates a number of log messages messages followed by a single + error message. It takes two parameters. The first parameter is an + integer corresponding to the number of logging events to + generate. The second parameter is the logback configuration + file. The last logging event generated by <em>EMail</em> + application, an ERROR, will trigger the transmission of an email + message. </p> - <p> - Here is a sample configuration file you can supply to chapter4.mail.Email: + <p>Here is a sample configuration file intended for the + <code>Email</code> application: </p> <em>Example 4.10: A sample <code>SMTPAppender</code> configuration (logback-examples/src/main/java/chapter4/mail/mail1.xml)</em> @@ -2023,7 +2030,8 @@ <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost> - <To>DESTINATION-EMAIL</To> + <To>EMAIL-DESTINATION</To> + <To>ANOTHER_EMAIL_DESTINATION</To> <!-- a second destination is optional --> <From>SENDER-EMAIL</From> <layout class="ch.qos.logback.classic.PatternLayout"> <Pattern>%date %-5level %logger{35} - %message%n</Pattern> Modified: logback/trunk/logback-site/src/site/pages/manual/index_menu.js ============================================================================== --- logback/trunk/logback-site/src/site/pages/manual/index_menu.js (original) +++ logback/trunk/logback-site/src/site/pages/manual/index_menu.js Thu Aug 28 09:43:26 2008 @@ -7,6 +7,5 @@ document.write('<p class="menu"><a href="layouts.html"><b>Ch5: Layouts</b></a>'); document.write('<p class="menu"><a href="filters.html"><b>Ch6: Filter chains</b></a>'); document.write('<p class="menu"><a href="mdc.html"><b>Ch7: Mapped Diagnostic Contexts</b></a>'); -document.write('<p class="menu"><a href="profilers.html"><b>Ch8: Profilers</b></a>'); -document.write('<p class="menu"><a href="contextSelector.html"><b>Ch9: Context Selectors</b></a>'); +document.write('<p class="menu"><a href="contextSelector.html"><b>Ch8: Context Selectors</b></a>'); Modified: logback/trunk/logback-site/src/site/pages/news.html ============================================================================== --- logback/trunk/logback-site/src/site/pages/news.html (original) +++ logback/trunk/logback-site/src/site/pages/news.html Thu Aug 28 09:43:26 2008 @@ -29,10 +29,11 @@ <hr width="80%" align="center" /> - <h3>XXth of XXX 2008 - Release of version 0.9.10</h3> + <h3>XXth of September 2008 - Release of version 0.9.10</h3> - <p>Logback-classic now prints its internal status in case of - errors. This has been a frequently requested feature. + <p>In case of errors during initialization, logback-classic now + <em>automatically</em> prints out its internal status. This has been + a frequently requested feature. </p> <p>The LogbackValve in logback-access (ensuring integration with @@ -59,6 +60,29 @@ developpers list. </p> + <p>Fixed issue <a + href="http://jira.qos.ch/browse/LBCORE-48">LBCORE-48</a>. During + rollover, compression of large files would bring all logging to a + halt. In this latest release, the rolled over file is first renamed, + which is a relatively fast operation, and only then is the renamed + file compressed asyncronously (in a separate thread). + </p> + + + <p>Fixed issue <a + href="http://jira.qos.ch/browse/LBCORE-27">LBCORE-27</a> reported by + Peter Royal. SMTPAppender now outputs its presentation footer and + file footer in the the correct order. + </p> + + <p>Fixed issue <a + href="http://jira.qos.ch/browse/LBCLASSIC-67">LBCLASSIC-67</a> + reported by Alessandro Fustini. SMTPAppender now correctly + configures the layout used to format the subject line of the + outgoing email. It no longer appends a lengthy stack trace to the + subject line. + </p> + <p><a href="http://jira.qos.ch/browse/LBCORE-32">LBCORE-32</a> </p>