Manages sending of logging information by mail.
Namespace:
CuttingEdge.LoggingAssembly: CuttingEdge.Logging (in CuttingEdge.Logging.dll)
Syntax
| Visual Basic (Declaration) |
|---|
Public Class MailLoggingProvider _ Inherits LoggingProviderBase |
| C# |
|---|
public class MailLoggingProvider : LoggingProviderBase |
| Visual C++ |
|---|
public ref class MailLoggingProvider : public LoggingProviderBase |
| JavaScript |
|---|
CuttingEdge.Logging.MailLoggingProvider = function(); Type.createClass( 'CuttingEdge.Logging.MailLoggingProvider', CuttingEdge.Logging.LoggingProviderBase); |
Remarks
Returning an identifier for the logged event is not appropriate for this provider. This provider will always return null (Nothing in VB) from the Log method.
This class is used by the Logger class to provide Logging services for an application that can connect to a configured SMTP Server. The MailLoggingProvider uses the configuration of the <system.net>/<mailSettings> section on the application configuration file.
The table below shows the list of valid attributes for the MailLoggingProvider configuration:
| Attribute | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | The name of the provider. This attribute is mandatory. | ||||||||||||
| description | A description of the provider. This attribute is optional. | ||||||||||||
| fallbackProvider | A fallback provider that this provider will use when logging failed. The value must contain the name of an existing logging provider. This attribute is optional. | ||||||||||||
| threshold | The logging threshold. The threshold limits the number of events logged. The threshold can be defined as follows: Debug < Information < Warning < Error < Critical. i.e., When the threshold is set to Information, events with a severity of Debug will not be logged. When no value is specified, all events are logged. This attribute is optional. | ||||||||||||
| to | A list of mail addresses, separated by a semicolon (;). This attribute is mandatory. | ||||||||||||
| subjectFormatString |
A format string that will be used to build the subject. The following indexed placeholders can
be used to format the subject.
|
Examples
This example demonstrates how to specify values declaratively for several attributes of the
Logging section, which can also be accessed as members of the LoggingSection class.
The following configuration file example shows how to specify values declaratively for the
Logging section.
Copy Code | |
|---|---|
|
<?xml version="1.0"?> <configuration> <configSections> <section name="logging" type="CuttingEdge.Logging.LoggingSection, CuttingEdge.Logging" allowDefinition="MachineToApplication" /> </configSections> <logging defaultProvider="MailLoggingProvider"> <providers> <add name="MailLoggingProvider" type="CuttingEdge.Logging.MailLoggingProvider, CuttingEdge.Logging" description="Mail logging provider" threshold="Information" to="developer1@cuttingedge.it;developer2@cuttingedge.it" subjectFormatString="Application error. {1} (Severity: {0})" /> </providers> </logging> <system.net> <mailSettings> <smtp from="test@foo.com"> <network host="smtpserver1" port="25" userName="john" password="secret" defaultCredentials="true" /> </smtp> </mailSettings> </system.net> </configuration> | |
Inheritance Hierarchy
System..::.Object
System.Configuration.Provider..::.ProviderBase
CuttingEdge.Logging..::.LoggingProviderBase
CuttingEdge.Logging..::.MailLoggingProvider
System.Configuration.Provider..::.ProviderBase
CuttingEdge.Logging..::.LoggingProviderBase
CuttingEdge.Logging..::.MailLoggingProvider