SmtpPickupDirAppender
The SmtpPickupDirAppender is configured similarly to the SmtpAppender.
The only difference is that rather than specify a SmtpHost parameter a PickupDir must be specified.
Because this appender writes the emails to disk and leaves their delivery to another process, it uses no SMTP client at all.
It is therefore unaffected by the deprecation of System.Net.Mail.SmtpClient, and remains a good option when you cannot take on the MailKit dependency that the recommended MailKit based SmtpAppender requires.
The PickupDir parameter is a path that must exist and the code executing the appender must have permission to create new files and write to them in this directory.
The path is relative to the application’s base directory (AppDomain.BaseDirectory).
The following example shows how to configure the SmtpPickupDirAppender to deliver log events via SMTP email.
The To, From, Subject and PickupDir are required parameters.
This example shows how to deliver only significant events.
A LevelEvaluator is specified with a threshold of WARN. This means that an email will be sent for each WARN or higher level message that is logged.
Each email will also contain up to 512 (BufferSize) previous messages of any level to provide context.
Messages not sent will be discarded.
<appender name="SmtpPickupDirAppender" type="log4net.Appender.SmtpPickupDirAppender">
<to value="to@example.com" />
<from value="from@example.com" />
<subject value="test logging message" />
<pickupDir value="C:\SmtpPickup" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="WARN"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger - %message%newline%newline" />
</layout>
</appender>