Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2B23611450 for ; Tue, 2 Sep 2014 16:09:12 +0000 (UTC) Received: (qmail 76354 invoked by uid 500); 2 Sep 2014 16:09:11 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 76302 invoked by uid 500); 2 Sep 2014 16:09:11 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 76291 invoked by uid 99); 2 Sep 2014 16:09:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2014 16:09:11 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mike.schall@gmail.com designates 209.85.217.172 as permitted sender) Received: from [209.85.217.172] (HELO mail-lb0-f172.google.com) (209.85.217.172) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2014 16:08:46 +0000 Received: by mail-lb0-f172.google.com with SMTP id 10so7993577lbg.3 for ; Tue, 02 Sep 2014 09:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=hwAjZSI1HSnRL3AA88vXFbLwfAPUihnoUcMGHvWtlIM=; b=BXXXKJeSqQ7Vj7V0ETv7twEJ1ZjYHR5iRgaZVaJ5gFyYfFS8u2BLcbhnq24i45qEj/ rZPT1lB4wo2gGpy+RsGpWtt1012kujuEtXL1dI2mN2AV7WJTls3KA6Sxv5NAo/7Q6bhY FgoGNR9u3WHUNGzdV40HvLMyZs4T+NZ+t7aROUPwVR7NJ8u2lnmpwop333SCyFXu7n/d 50cNjTe7zs/bDrWooNPP+tfjgGakjMW5ahqNczh2rPSDSUEKKP3o7wQODR8r6R5kAIFF XQ6QyiFi1WOb3iqwmJyBJnNX0F+PoS5ycrfRQv+/5mMw/mRzoaTv4blLggwuXFCrc2/q qFvw== MIME-Version: 1.0 X-Received: by 10.112.160.38 with SMTP id xh6mr34164833lbb.21.1409674125299; Tue, 02 Sep 2014 09:08:45 -0700 (PDT) Received: by 10.152.185.35 with HTTP; Tue, 2 Sep 2014 09:08:45 -0700 (PDT) In-Reply-To: References: <41A8992A-E605-482A-8E58-282DDDFE4FFC@dslextreme.com> <8784959322575996390@unknownmsgid> <47BED40E-4CCE-420E-91F8-789742B15EDC@gmail.com> Date: Tue, 2 Sep 2014 11:08:45 -0500 Message-ID: Subject: Re: Extending Appenders From: Michael Schall To: Log4J Users List Content-Type: multipart/alternative; boundary=001a11c2b8167cd51e0502175539 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2b8167cd51e0502175539 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks for all your input. I'm going to try and implement the appender we need to maintain our current throttling infrastructure. I will send a patch with the changes we need as far as moving items from private to protected and removing the final keyword. On Sat, Aug 30, 2014 at 2:02 PM, Matt Sicker wrote: > http://logging.apache.org/log4j/2.x/manual/filters.html#BurstFilter > http://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender > > There are several ways to go about implementing what you're asking about > using existing features. You may be able to get what you need by using ju= st > the burst filter and routing appender (which itself may not be required > depending on your usage). > > > On 30 August 2014 09:27, Jeff Shaw wrote: > > > It sounds like a feature that belongs to any logger. Syslog doesn't nee= d > > to know that a database server is unavailable every nanosecond, either. > > > > Sent from my phone > > > > > On Aug 30, 2014, at 3:19 AM, Remko Popma > wrote: > > > > > > This sounds like a good feature to have in log4j2. I remember we had = an > > issue at work where error logs were emailed automatically, bringing dow= n > > the mail server when the app kept generating the same error. Painful. > > > > > > Sent from my iPhone > > > > > >> On 2014/08/30, at 7:24, Michael Schall wrote= : > > >> > > >> Again, thanks for all the interest in my request. > > >> > > >> I don't have the code in front of me, but I will try and give an > > >> overview of what we did for log4j 1.x. > > >> > > >> We want to send emails for errors happening in production. However f= or > > >> example, we don't want to send thousands of emails if the network go= es > > >> down to a database. If we have an issue that attempts to send more > > >> than X emails in a timeframe, we want to only send 1 email at high > > >> priority and "archive" the rest. If the issue is not resolved we ma= y > > >> send multiple high priority emails until the issue is resolved, but > > >> only a fraction of the emails are actually sent. > > >> > > >> We have a standalone service that does all the throttling logic by > > >> watching a folder for file creations. So the appender I'm talking > > >> about writing doesn't actually send emails. It just does everything > > >> the SmtpAppender does (buffering, evaluating, ...), but writes a fi= le > > >> to a "watch" folder instead of sending messages. The service then > > >> either sends the mail or throttles and sends at high priority. > > >> > > >> So, my thought is that I would extend the SmtpAppender and override > > >> the sendEvents method to write out the contents of the buffer to a > > >> file. This approach has worked great with log4j 1.x. > > >> > > >> Mike > > >> > > >>> On Aug 29, 2014, at 11:28 PM, Ralph Goers < > ralph.goers@dslextreme.com> > > wrote: > > >>> > > >>> This is a fair point. There are some things not in the API that we > > wouldn=E2=80=99t change as they would also break compatibility, such as= the > Layout > > or Appender interface, but we aren=E2=80=99t guaranteeing that specific= Appender > or > > Layout instances won=E2=80=99t have a new parameter added to them or th= ings like > > that. > > >>> > > >>> Ralph > > >>> > > >>>> On Aug 29, 2014, at 3:22 PM, Remko Popma > > wrote: > > >>>> > > >>>> I would not object to changing SmtpAppender to make it more > > extendible. > > >>>> > > >>>> Can you tell me more about your use case? SmtpAppender is designed > > this way > > >>>> because we had a specific usage in mind. By understanding your use > > case we > > >>>> might be able to improve the design in a way that benefits not jus= t > > you but > > >>>> other users as well. What do you want to do that you can't do with > the > > >>>> current SmtpAppender? > > >>>> > > >>>> Looks like several changes are required. I am away from my PC and > > can't > > >>>> judge the details now. Could you raise a feature request Jira and > > attach a > > >>>> patch that includes all the changes you'd like to make? That might > > save us > > >>>> some going back and forth. > > >>>> > > >>>> Thanks! > > >>>> Remko > > >>>> > > >>>>> On Friday, August 29, 2014, Michael Schall > > wrote: > > >>>>> > > >>>>> Thanks for your response Remko. > > >>>>> > > >>>>> Looking into this further, I could duplicate the SmtpAppender cod= e > > as it > > >>>>> really just seems to do plugin work. The bulk of the code is in > the > > >>>>> SmtpManager class which is not marked final. The constructor is > > marked > > >>>>> protected, however it takes a private class (FactoryData). I wou= ld > > also > > >>>>> like to override the sendEvents method, but then I run into issue= s > > because > > >>>>> the buffer is private. > > >>>>> > > >>>>> Do these changes seem like an issue? > > >>>>> > > >>>>> Mike > > >>>>> > > >>>>> > > >>>>> On Fri, Aug 29, 2014 at 4:51 PM, Remko Popma < > remko.popma@gmail.com > > >>>>> > wrote: > > >>>>> > > >>>>>> Looks like this class was made final in January 2013. The commit > > message > > >>>>>> mentions checkstyle errors. > > >>>>>> What change are you proposing? Would just removing the final > > keyword from > > >>>>>> the class definition be enough to fulfill your needs? > > >>>>>> > > >>>>>> It may be good to raise this as a feature request in Jira. > > >>>>>> If you need more changes than just making the class non-final, > > please > > >>>>>> attach a patch with the changes you have in mind. > > >>>>>> > > >>>>>> > > >>>>>> On Sat, Aug 30, 2014 at 4:07 AM, Michael Schall < > > mike.schall@gmail.com > > >>>>> > > > >>>>>> wrote: > > >>>>>> > > >>>>>>> I'm upgrading an application to use Log4j2. With our existing > > >>>>>>> implementation we have created a new appender which extends the > > >>>>>>> SMTPAppender. I see the SMTPAppender is a final class now whic= h > > >>>>> prevents > > >>>>>>> me from extending it. I was wondering what the reason for this > > is? Do > > >>>>>> we > > >>>>>>> really need to re-implement the the entire SMTPAppender > > (properties, > > >>>>>>> buffering, ...) to extend the appender? > > >>>>>>> > > >>>>>>> Thanks for your time. > > >>>>>>> > > >>>>>>> Mike > > >> > > >> --------------------------------------------------------------------= - > > >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > > >> For additional commands, e-mail: log4j-user-help@logging.apache.org > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > > > For additional commands, e-mail: log4j-user-help@logging.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > > For additional commands, e-mail: log4j-user-help@logging.apache.org > > > > > > > -- > Matt Sicker > --001a11c2b8167cd51e0502175539--