logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: [log4j 1.x] Batch-sending with SMTPAppender
Date Wed, 16 Nov 2016 17:11:24 GMT

On 11/16/16 9:49 AM, Ralph Goers wrote:
> First, I have to say that Log4j 1 reached end-of-life over a year
> ago. We recommend you upgrade to Log4j 2.

Fair enough. I'm not quite there, yet. I suspect that log4j 2 will have
the same issue, though.

> I don’t know what you mean by “each log message seems to generate its
> own separate email message”. The SMTP appender accumulates log events
> in a buffer until a triggering event occurs (usually an error event)
> and then all the buffered events are sent in an email.

This is not what I'm seeing. I'm seeing e.g. 10 ERROR messages logged in
the span of about a minute to the main log file (e.g. my-process.log on
the disk) and then 10 separate email messages with one log line per
message in them.

I have an example from 09:25 US-Eastern this morning: I got 7 separate
email messages. The first message has this content (timestamps are UTC):

2016-11-16 14:25:52,893 [main] ERROR [...logger and message content...]

The last one has this content:

2016-11-16 14:27:13,569 [main] ERROR [...logger and message content...]

So in the space of about 90 seconds, log4j sent 7 separate email
messages, and each email message contained a single log line.

I happen to be using log4j 1.2.17 which was the final release of log4j 1.x.

When you say "an error event" will trigger an email to be sent... do you
mean a log.error() call? If so, perhaps the problem is that my threshold
has been set to ERROR so I'm only reacting to ERROR events. If I were
logging at the TRACE level, would I get a whole bunch of TRACE and a
single ERROR in each email message?

Looking at the javadoc, it seems like that might be the case:

The default constructor will instantiate the appender with a
TriggeringEventEvaluator that will trigger on events with level ERROR or

I'm using a .properties file to configure log4j. How can I configure a
TriggeringEventEvaluator to, saw, only trigger on e.g. FATAL log events?

> This happens each time a triggering event occurs. I see the logic for
> sendOnClose and expect what you are doing should work, but I haven’t
> worked with the Log4j 1 code in years so I can’t say for sure.


View raw message