SmtpAppender Class | Apache log4net™ SDK Documentation

Send an e-mail when a specific logging event occurs, typically on errors or fatal errors.
Inheritance Hierarchy

System
Object
log4net.Appender
AppenderSkeleton
log4net.Appender
BufferingAppenderSkeleton
log4net.Appender
SmtpAppender

Namespace: log4net.Appender
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    public class SmtpAppender : BufferingAppenderSkeleton

    Public Class SmtpAppender
    	Inherits BufferingAppenderSkeleton

    public ref class SmtpAppender : public BufferingAppenderSkeleton

    type SmtpAppender =
        class
            inherit BufferingAppenderSkeleton
        end

The SmtpAppender type exposes the following members.

Constructors

| Name | Description
--- | --- | ---
| SmtpAppender | Default constructor

Top
Properties

| Name | Description
--- | --- | ---
| Authentication | The mode to use to authentication with the SMTP server
| Bcc | Gets or sets a semicolon-delimited list of recipient e-mail addresses that will be blind carbon copied.
| BodyEncoding | Gets or sets the body encoding to be used.
| BufferSize | Gets or sets the size of the cyclic buffer used to hold the logging events. (Inherited from BufferingAppenderSkeleton.)
| Cc | Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses that will be carbon copied (use semicolon on .NET 1.1 and comma for later versions).
| EnableSsl | Enable or disable use of SSL when sending e-mail message
| ErrorHandler | Gets or sets the IErrorHandler for this appender. (Inherited from AppenderSkeleton.)
| Evaluator | Gets or sets the ITriggeringEventEvaluator that causes the buffer to be sent immediately. (Inherited from BufferingAppenderSkeleton.)
| FilterHead | The filter chain. (Inherited from AppenderSkeleton.)
| Fix | Gets or sets a the fields that will be fixed in the event (Inherited from BufferingAppenderSkeleton.)
| From | Gets or sets the e-mail address of the sender.
| Layout | Gets or sets the ILayout for this appender. (Inherited from AppenderSkeleton.)
| LocationInfo | Obsolete. Obsolete
| Lossy | Gets or sets a value that indicates whether the appender is lossy. (Inherited from BufferingAppenderSkeleton.)
| LossyEvaluator | Gets or sets the value of the ITriggeringEventEvaluator to use. (Inherited from BufferingAppenderSkeleton.)
| Name | Gets or sets the name of this appender. (Inherited from AppenderSkeleton.)
| OnlyFixPartialEventData | Obsolete. Gets or sets a value indicating if only part of the logging event data should be fixed. (Inherited from BufferingAppenderSkeleton.)
| Password | The password to use to authenticate with the SMTP server
| Port | The port on which the SMTP server is listening
| Priority | Gets or sets the priority of the e-mail message
| ReplyTo | Gets or sets the reply-to e-mail address.
| RequiresLayout | This appender requires a log4net.Layout to be set. (Overrides AppenderSkeleton RequiresLayout.)
| SmtpHost | Gets or sets the name of the SMTP relay mail server to use to send the e-mail messages.
| Subject | Gets or sets the subject line of the e-mail message.
| SubjectEncoding | Gets or sets the subject encoding to be used.
| Threshold | Gets or sets the threshold Level of this appender. (Inherited from AppenderSkeleton.)
| To | Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses (use semicolon on .NET 1.1 and comma for later versions).
| Username | The username to use to authenticate with the SMTP server

Top
Methods

| Name | Description
--- | --- | ---
| ActivateOptions | Initialize the appender based on the options set (Inherited from BufferingAppenderSkeleton.)
| AddFilter | Adds a filter to the end of the filter chain. (Inherited from AppenderSkeleton.)
| Append( LoggingEvent ) | Append a bulk array of logging events. (Inherited from AppenderSkeleton.)
| Append(LoggingEvent) | This method is called by the DoAppend(LoggingEvent) method. (Inherited from BufferingAppenderSkeleton.)
| ClearFilters | Clears the filter list for this appender. (Inherited from AppenderSkeleton.)
| Close | Closes the appender and release resources. (Inherited from AppenderSkeleton.)
| DoAppend(LoggingEvent) | Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent)] method. (Inherited from AppenderSkeleton.)
| DoAppend( LoggingEvent ) | Performs threshold checks and invokes filters before delegating actual logging to the subclasses specific [M:Append(LoggingEvent[])] method. (Inherited from AppenderSkeleton.)
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
| FilterEvent | Test if the logging event should we output by this appender (Inherited from AppenderSkeleton.)
| Finalize | Finalizes this appender by calling the implementation's Close method. (Inherited from AppenderSkeleton.)
| Flush | Flush the currently buffered events (Inherited from BufferingAppenderSkeleton.)
| Flush(Boolean) | Flush the currently buffered events (Inherited from BufferingAppenderSkeleton.)
| Flush(Int32) | Flushes any buffered log data. (Inherited from BufferingAppenderSkeleton.)
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.)
| GetType | Gets the Type of the current instance. (Inherited from Object.)
| IsAsSevereAsThreshold | Checks if the message level is below this appender's threshold. (Inherited from AppenderSkeleton.)
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.)
| OnClose | Close this appender instance. (Inherited from BufferingAppenderSkeleton.)
| PreAppendCheck | Called before [M:Append(LoggingEvent)] as a precondition. (Inherited from AppenderSkeleton.)
| RenderLoggingEvent(LoggingEvent) | Renders the LoggingEvent to a string. (Inherited from AppenderSkeleton.)
| RenderLoggingEvent(TextWriter, LoggingEvent) | Renders the LoggingEvent to a string. (Inherited from AppenderSkeleton.)
| SendBuffer | Sends the contents of the cyclic buffer as an e-mail message. (Overrides BufferingAppenderSkeleton SendBuffer( LoggingEvent ).)
| SendEmail | Send the email message
| SendFromBuffer | Sends the contents of the buffer. (Inherited from BufferingAppenderSkeleton.)
| ToString | Returns a String that represents the current Object. (Inherited from Object.)

Top
Remarks

The number of logging events delivered in this e-mail depend on the value of BufferSize option. The SmtpAppender 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.

Caution
Authentication and setting the server Port are only available on the MS .NET 1.1 runtime. For these features to be enabled you need to ensure that you are using a version of the log4net assembly that is built against the MS .NET 1.1 framework and that you are running the your application on the MS .NET 1.1 runtime. On all other platforms only sending unauthenticated messages to a server listening on port 25 (the default) is supported.

Authentication is supported by setting the Authentication property to either Basic or Ntlm. If using Basic authentication then the Username and Password properties must also be set.

To set the SMTP server port use the Port property. The default port is 25.

See Also

#### Reference

log4net.Appender Namespace