Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F294118C7F for ; Thu, 3 Dec 2015 16:17:24 +0000 (UTC) Received: (qmail 82500 invoked by uid 500); 3 Dec 2015 16:17:11 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 82400 invoked by uid 500); 3 Dec 2015 16:17:11 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 81748 invoked by uid 99); 3 Dec 2015 16:17:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 16:17:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 134F82C1F74 for ; Thu, 3 Dec 2015 16:17:11 +0000 (UTC) Date: Thu, 3 Dec 2015 16:17:11 +0000 (UTC) From: "Thies Wellpott (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LOG4J2-1192) Dynamic Subject for SMTP Appender MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-1192?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D150= 38013#comment-15038013 ]=20 Thies Wellpott commented on LOG4J2-1192: ---------------------------------------- Hi! I created a new Appender (ExtendedSmtpAppender) which optionally allows to = use PatternLayout for the subject. Additionally, it supports burst summarizing, so you will not get 1000 error= emails wihtin a few seconds or minutes. Use case: Send all ERROR-logs via = Email to support/developer. On a broken network or database this can cause = hundreds of the same error email. This appender does the following: - the first occurrence is email immediatly - all following similar ERROR logs are buffered for a certain time (similar= ity and time is configurable) - after the time passed, a summary email with summary info (number of event= s, time) and the first and last event is send See two attached source codes (the may be moved into the org.apache.logging= .log4j.core package and included into the log4j2 project). Example configuration (inside ): =09=09" to=3D"${errorEmailAddre= sses}" =09=09=09=09subject=3D"[PROJECT-ID, ${hostName}, ${web:contextPath}] %p: %c= {1} - %m%notEmpty{ =3D>%ex{short})}" =09=09=09=09subjectWithLayout=3D"true" bufferSize=3D"5" =09=09=09=09burstSummarizingSeconds=3D"300" bsCountInSubject=3D"S" bsMessag= eMaskDigits=3D"true" =09=09=09=09bsExceptionOrigin=3D"true" > =09=09=09=09=09 =09=09 =09=09 =09=09=09 =09=09 > Dynamic Subject for SMTP Appender > --------------------------------- > > Key: LOG4J2-1192 > URL: https://issues.apache.org/jira/browse/LOG4J2-1192 > Project: Log4j 2 > Issue Type: New Feature > Components: Appenders > Affects Versions: 2.4.1 > Environment: ALL > Reporter: J=C3=B6rg Bretschneider > Labels: features > > It is annoying to have log messages sent to users via SMTP Appender with = a static subject, requiring recipients to open each of possibly a vast amou= nt of log emails in order to find out what went wrong. > Users should be able to insert runtime diagnostic context information to = the message text AND to the message subject as well.=20 > While the first seems to be working with Patternlayout using the mechanis= m with the %X{} pattern based on a NDC or MDC in the "Conversion= Pattern" parameter, it does NOT work with the "Subject" parameter with log4= j (neither 1.2 nor 2.x), though some bloggers suggest it, e.g. http://stack= overflow.com/a/7015453.=20 > See http://stackoverflow.com/questions/29435825/log4j2-custom-email-subje= ct-from-map as an example where others found this also. > This issue should have been fixed long ago. > I suggest to extend SMTP appender in order to be able to use %X and other= Pattern conversion in the "Subject" parameter properly.=20 > http://openutils.sourceforge.net/openutils-log4j/smtpappender.html=20 > has already done the part for applying PatternLayout to the SMTP Appender= "Subject". I didn't test if this works properly.=20 > Maybe this work can be included into log4j with minimal effort? > This feature has originally been realized in LOGBACK using an MDC in Patt= ernlayouts: http://logback.qos.ch/manual/mdc.html -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org