Matej,

The docs may not be clear on this, but i believe this buffer is essentially for 
multithreaded access. 

Every event will be stored in the buffer, and then trigger a send(). You are 
right that sending happens in the calling thread. You could consider wrapping 
the smtp appender in an async appender. 

When a send happens, it will grab all events currently in the buffer and send 
them in a single email. 

I believe this is correct behavior. Otherwise you may only have one ERROR and 
the email never gets sent because the appender is waiting for 9 more events...

Best regards,
Remko

Sent from my iPhone

On 2013/05/09, at 21:32, Matej Vitásek <[email protected]> wrote:

> Hi all,
> 
> I'd like to report 2 problems I am encountering using the SMTPAppender. I
> am using it* to send me mails whenever an ERROR is logged in a web
> application.
> 
> 1) Buffer size is ignored. Excerpt from my log4j2.xml:
> <SMTP name="Mail" suppressExceptions="false" subject="Error Log"
> to="..." from="..." smtpHost="smtp.gmail.com"
> smtpPort="465" *bufferSize="10"* smtpProtocol="smtps" smtpUsername="..."
> smtpPassword="...">
> </SMTP>
> 
> You will notice that the buffer size is 10. I'd expect to be getting
> e-mails with 10 errors aggregated, but every e-mail always contains only
> one error.
> 
> Looking into SMTPAppender.append() I see a call to manager.sendEvents()
> which does not aggregate the message - it just sends it. To me it seems
> that append() should write into SMTPManager.buffer and send only if it's
> full...
> 
> 2) Sending the e-mail blocks the thread that logged the error. I don't know
> how to "prove" this empirically, it's just a really clear subjective
> feeling: whenever an error gets logged, the whole application just lags for
> the time it takes to send the mail.
> 
> Can I provide you some help in pinpointing this problem?
> 
> 
> Overall: just ask if you need more information,
> 
> 
> Thanks!
> 
> 
> Matej

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to