MailBee.NET Objects 4.0

Logger Class

Provides logging facilities for MailBee components such as Smtp, Pop3, and Imap.

For a list of all members of this type, see Logger Members.

System.Object
   MailBee.Logger

public class Logger

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

The logging is the first tool to use for troubleshooting. If you encounter any problems with Smtp, Pop3 or Imap component, please enable the logging first, and try again.

The log provides a lot of useful and detailed information on how MailBee communicates with mail or DNS servers. The logs keeps track of all occurred network connection and protocol errors as well.

Logger class also supports logging into memory buffer instead of a file (useful for those ASP.NET applications which have no permissions to write to disk).

To prevent unlimited growth of the log file/memory buffer, the maximum size of the log can be restricted to certain value (see MaxSize property).

The developer has control of adding log messages. Each time the log entry is to be added into the log, MailBee components raise LogNewEntry event (see Smtp.LogNewEntry, Pop3.LogNewEntry, and Imap.LogNewEntry). Also, the developer can explicitly put new entries into the log using WriteLine method.

Example

This sample enables logging POP3 session into C:\pop3_log.txt file. The maximum size of the log file is restricted to 4 Kbytes. If the log file is going to exceed this size, it's renamed into C:\pop3_log-bak.txt, and new C:\pop3_log.txt log is started.

Note   If C:\pop3_log.txt gets full again, it's again renamed to C:\pop3_log-bak.txt (old C:\pop3_log-bak.txt contents will be lost). Thus, the log will always reflect the latest activity, however, older data may be lost.
[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

// The actual code (put it into a method of your class)
Pop3 pop = new Pop3();

// Set logging parameters.
pop.Log.Enabled = true;
pop.Log.Filename = @"C:\pop3_log.txt";
pop.Log.MaxSize = 4096;
pop.Log.OldFilename = @"C:\pop3_log-bak.txt";

// Download all message headers to produce some log messages.
pop.Connect("mail.domain.com");
pop.Login("user@domain.com", "password");
MailMessageCollection msgs = pop.DownloadMessageHeaders();
pop.Disconnect();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Pop3Mail
Imports MailBee.Mime

' The actual code (put it into a method of your class).
Dim pop As New Pop3

' Set logging parameters.
pop.Log.Enabled = True
pop.Log.Filename = "C:\pop3_log.txt"
pop.Log.MaxSize = 4096
pop.Log.OldFilename = "C:\pop3_log-bak.txt"

' Download all message headers to produce some log messages.
pop.Connect("mail.domain.com")
pop.Login("user@domain.com", "password")

Dim msgs As MailMessageCollection
msgs = pop.DownloadMessageHeaders()
pop.Disconnect()

Requirements

Namespace: MailBee

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

Logger Members | MailBee Namespace