How do you get log4net's SmtpPickupDirAppender to use the IIS pickup directory?

StackOverflow https://stackoverflow.com/questions/242908

  •  04-07-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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

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