tags:

views:

190

answers:

2

Due to the nature of the live server I deploy to, my mail settings are using deliveryMethod="PickupDirectoryFromIis". I'm using log4net to send logs via email and I need find a way of getting it to do the same thing.

I can see from the docs that there is an SmtpPickupDirAppender, which has a pickupDir setting. If I set this to whatever pickup directory IIS uses, I'm sure everything will work OK. However what I really want is to just tell log4net to use IIS's setting and leave it there. That way if it ever changes we won't have to change the log4net config too, something we're likely to forget. Is there a way to do this?

+1  A: 

AFAIK, that's not possible. Although it sounds like a good idea.

One of the greatest things about log4net is that you can change your configuration without having to restart or recompile the application (check the FAQ), so you don't need to worry about having a downtime in your logging.

I don't know if you can query the IIS for the SMTP pick up directory, maybe if this is possible you can add some background job that queries the IIS for this information?

Leandro López
I agree, looking at the source code for log4net it would appear it doesn't support this.
gilles27
A: 

It is a shame because the SmtpClient.DeliveryMethod property supports a value of PickupDirectoryFromIis.

Leandro López
Yes, that's the point I was trying to make, .NET provides this feature but log4net has not taken advantage of it. However I suppose their response would be, "send us a patch for it!", and they would probably be right :-)
gilles27
Yes, I was thinking the same. But I'm feeling so lazy right now! :PAlthough I think it would be a great contribution.
Leandro López