Question

I am running a Windows Service on a Windows Server 2003 R2. We are using Exchange Server to send out the emails.

I am using log4net.dll 1.2.11.0.

I have situation where log4net sometimes sends emails and sometimes don't eventhough no changes has been made to the set up.

All the other log4net logging works very fine. And as said sometimes the application sends out emails and some times it don't, having made no change to the application.

All my methods are in try-catch clauses, but I don't get any errors.

When I run the the Windows Service on my local machine, the log4net email always works, and as said on the remote server, sometimes the log4net email works, sometimes it don't, having made no changes to the setup.

I am using log4net.Internal.Debug and have a System.Diagnostics.TextWriterTraceListener file where stuff is written to. Scanning thorugh this file I haven't noticed anything in particular, but I don't know what specific to look for.

Any ideas about what the problem is or what to do?

Was it helpful?

Solution

If the SMTP appender cannot send an email it would log an exception with this text: Error occurred while sending e-mail notification. This would be visible if internal debugging is enabled. Maybe you have filters or something like that configured that prevents log4net from sending an email.

You could download the source code of log4net and add extra logging to the SMTP appender to find out if the "SendMail" method of the appender gets called at all. If it does and no email and no error is shown, then we need to assume that the exchange server somehow swallows the emails. If the appender is not triggered, then you need to review your filter / buffer / threshold configuration.

Alternatively you could try to use the SmtpPickupDirAppender.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top