From: <fg...@us...> - 2009-02-21 17:49:46
|
Revision: 1051 http://openutils.svn.sourceforge.net/openutils/?rev=1051&view=rev Author: fgiust Date: 2009-02-21 17:49:38 +0000 (Sat, 21 Feb 2009) Log Message: ----------- ready for 2.0.4 Modified Paths: -------------- trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java trunk/openutils-log4j/src/site/changes/changes.xml Modified: trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java =================================================================== --- trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java 2009-02-20 21:38:47 UTC (rev 1050) +++ trunk/openutils-log4j/src/main/java/it/openutils/log4j/AlternateSMTPAppender.java 2009-02-21 17:49:38 UTC (rev 1051) @@ -73,10 +73,12 @@ * <param name="ConversionPattern" value="%-5p %c %d{dd.MM.yyyy HH:mm:ss} -- %m%n" /> * <param name="Header" * value=" - * =================================== - * Myapp (production environment) - * Date: %d{dd.MM.yyyy HH:mm:ss} - * =================================== + * ===================================%n + * Myapp (production environment)%n + * Date: %d{dd.MM.yyyy HH:mm:ss}%n + * Url: %X{url}%n + * Number of occurrences: %o%n + * ===================================%n * " /> * </layout> * </appender> @@ -123,6 +125,8 @@ private Layout subjectLayout; + private Layout headerLayout; + private String smtpHost; private boolean locationInfo; @@ -204,6 +208,8 @@ event.getThreadName(); event.getNDC(); + event.getMDCCopy(); + if (locationInfo) { event.getLocationInformation(); @@ -348,17 +354,26 @@ MimeBodyPart part = new MimeBodyPart(); StringBuffer sbuf = new StringBuffer(); - String t = layout.getHeader(); - if (t != null) + + LoggingEvent event = lea.getLoggingEvent(); + + if (layout.getHeader() != null) { - t = StringUtils.replace(t, "%o", Integer.toString(lea.getCount())); - t = StringUtils.replace(t, "%n", Layout.LINE_SEP); - sbuf.append(t); - sbuf.append("\n"); + if (headerLayout == null) + { + String header = layout.getHeader(); + header = StringUtils.replace(header, "%o", "{number_of_occurrences}"); + headerLayout = new PatternLayout(header); + } + String t = headerLayout.format(event); + if (t != null) + { + t = StringUtils.replace(t, "{number_of_occurrences}", Integer.toString(lea.getCount())); + sbuf.append(t); + sbuf.append("\n"); + } } - LoggingEvent event = lea.getLoggingEvent(); - if (this.subjectLayout != null) { String subject = this.subjectLayout.format(event); @@ -387,7 +402,7 @@ } } } - t = layout.getFooter(); + String t = layout.getFooter(); if (t != null) { t = StringUtils.replace(t, "%n", Layout.LINE_SEP); @@ -462,8 +477,8 @@ } /** - * The <b>SMTPHost</b> option takes a string value which should be a the host name of the SMTP server that will - * send the e-mail message. + * The <b>SMTPHost</b> option takes a string value which should be a the host name of the SMTP server that will send + * the e-mail message. */ public void setSMTPHost(String smtpHost) { @@ -496,9 +511,9 @@ } /** - * The <b>EvaluatorClass</b> option takes a string value representing the name of the class implementing the {@link - * TriggeringEventEvaluator} interface. A corresponding object will be instantiated and assigned as the triggering - * event evaluator for the SMTPAppender. + * The <b>EvaluatorClass</b> option takes a string value representing the name of the class implementing the + * {@link TriggeringEventEvaluator} interface. A corresponding object will be instantiated and assigned as the + * triggering event evaluator for the SMTPAppender. */ public void setEvaluatorClass(String value) { @@ -517,10 +532,9 @@ } /** - * The <b>LocationInfo</b> option takes a boolean value. By default, it is set to false which means there will be - * no effort to extract the location information related to the event. As a result, the layout that formats the - * events as they are sent out in an e-mail is likely to place the wrong location information (if present in the - * format). + * The <b>LocationInfo</b> option takes a boolean value. By default, it is set to false which means there will be no + * effort to extract the location information related to the event. As a result, the layout that formats the events + * as they are sent out in an e-mail is likely to place the wrong location information (if present in the format). * <p> * Location information extraction is comparatively very slow and should be avoided unless performance is not a * concern. Modified: trunk/openutils-log4j/src/site/changes/changes.xml =================================================================== --- trunk/openutils-log4j/src/site/changes/changes.xml 2009-02-20 21:38:47 UTC (rev 1050) +++ trunk/openutils-log4j/src/site/changes/changes.xml 2009-02-21 17:49:38 UTC (rev 1051) @@ -8,6 +8,11 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="2.0.4" date="2009-02-21" description="2.0.4"> + <action type="add" dev="fgiust">Added support for using MDC in AlternateSMTPAppender</action> + <action type="add" dev="fgiust">AlternateSMTPAppender now handles the layour header as a + PatternLayout and not as a static String anymore.</action> + </release> <release version="2.0.3" date="2009-01-31" description="2.0.3"> <action type="update" dev="fgiust"> Updated log4j dependency to 1.2.15 with the necessary exclusion (1.2.15 brings in several optional/unwanted dependencies with maven)</action> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |