logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [log4j 1.x] Batch-sending with SMTPAppender
Date Wed, 16 Nov 2016 17:59:53 GMT

> On Nov 16, 2016, at 10:11 AM, Christopher Schultz <chris@christopherschultz.net>
> Ralph,
> 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.

If your application isn’t logging any other events (info, debug, etc) in between the errors
then this behavior is correct. It would also be correct if you have filtering set up so that
the log events never reach the SMTP appender as it can only place the events in its buffer
that reach it. So if your loggers are set to error you could only see the error events in
the emails and each would be sent separately as each is a triggering event. And yes, a call
to logger.error() generates an error event while logger.debug would generate a debug event.

I don’t know how to configure a TriggeringEventEvaluator in Log4j 1 but I’d bet google
does ;-)


> 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
> higher.
> "
> 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.
> Thanks,
> -chris

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message