Class SmtpPickupDirAppender
Send an email when a specific logging event occurs, typically on errors or fatal errors. Rather than sending via smtp it writes a file into the directory specified by PickupDir. This allows services such as the IIS SMTP agent to manage sending the messages.
public class SmtpPickupDirAppender : BufferingAppenderSkeleton, IBulkAppender, IAppender, IOptionHandler, IFlushable
- Inheritance
-
SmtpPickupDirAppender
- Implements
- Inherited Members
Remarks
The configuration for this appender is identical to that of the SMTPAppender,
except that instead of specifying the SMTPAppender.SMTPHost you specify
PickupDir.
The number of logging events delivered in this e-mail depend on the value of BufferSize option. The SmtpPickupDirAppender keeps only the last BufferSize logging events in its cyclic buffer. This keeps memory requirements at a reasonable level while still delivering useful application context.
Constructors
SmtpPickupDirAppender()
Default constructor
public SmtpPickupDirAppender()
Remarks
Default constructor
Properties
FileExtension
Gets or sets the file extension for the generated files
public string FileExtension { get; set; }
Property Value
- string
The file extension for the generated files
Remarks
The file extension for the generated files
From
Gets or sets the e-mail address of the sender.
public string From { get; set; }
Property Value
- string
The e-mail address of the sender.
Remarks
The e-mail address of the sender.
PickupDir
Gets or sets the path to write the messages to.
public string PickupDir { get; set; }
Property Value
Remarks
Gets or sets the path to write the messages to. This should be the same as that used by the agent sending the messages.
RequiresLayout
This appender requires a log4net.Layout to be set.
protected override bool RequiresLayout { get; }
Property Value
- bool
true
Remarks
This appender requires a log4net.Layout to be set.
SecurityContext
Gets or sets the SecurityContext used to write to the pickup directory.
public SecurityContext SecurityContext { get; set; }
Property Value
- SecurityContext
The SecurityContext used to write to the pickup directory.
Remarks
Unless a SecurityContext specified here for this appender the DefaultProvider is queried for the security context to use. The default behavior is to use the security context of the current thread.
Subject
Gets or sets the subject line of the e-mail message.
public string Subject { get; set; }
Property Value
- string
The subject line of the e-mail message.
Remarks
The subject line of the e-mail message.
To
Gets or sets a semicolon-delimited list of recipient e-mail addresses.
public string To { get; set; }
Property Value
- string
A semicolon-delimited list of e-mail addresses.
Remarks
A semicolon-delimited list of e-mail addresses.
Methods
ActivateOptions()
Activate the options on this appender.
public override void ActivateOptions()
Remarks
This is part of the IOptionHandler delayed object activation scheme. The ActivateOptions() method must be called on this object after the configuration properties have been set. Until ActivateOptions() is called this object is in an undefined state and must not be used.
If any of the configuration properties are modified then ActivateOptions() must be called again.
ConvertToFullPath(string)
Convert a path into a fully qualified path.
protected static string ConvertToFullPath(string path)
Parameters
pathstringThe path to convert.
Returns
- string
The fully qualified path.
Remarks
Converts the path specified to a fully qualified path. If the path is relative it is taken as relative from the application base directory.
SendBuffer(LoggingEvent[])
Sends the contents of the cyclic buffer as an e-mail message.
protected override void SendBuffer(LoggingEvent[] events)
Parameters
eventsLoggingEvent[]The logging events to send.
Remarks
Sends the contents of the cyclic buffer as an e-mail message.