Provides flags which can be used to change formatting of log messages produced by MailBee.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
This sample demonstrates the effect of different LogFormatOptions flags.
Note The actual values can be different in your case.
[C#] using System; using MailBee; using MailBee.SmtpMail; class Sample { // LogNewEntry event handler. private static void OnLogNewEntry(object sender, LogNewEntryEventArgs e) { // For readability, reduce the number of log entries displayed. if (e.NewEntry.MessageType != LogMessageType.Recv) { e.NewEntry.AddThisEntry = false; } } // The actual code. static void Main(string[] args) { Smtp mailer = new Smtp(); mailer.SmtpServers.Add("smtp.domain.com"); // Enable logging the SMTP session into memory. mailer.Log.Enabled = true; mailer.Log.MemoryLog = true; // Subscribe to the LogNewEntry event. mailer.LogNewEntry += new LogNewEntryEventHandler(OnLogNewEntry); mailer.Log.Clear(); mailer.Connect(); Console.WriteLine("Format is None"); Console.WriteLine(mailer.Log.GetMemoryLog()); mailer.Log.Clear(); mailer.Log.Format = LogFormatOptions.AddContextInfo; mailer.Hello(); Console.WriteLine("Format is AddContextInfo"); Console.WriteLine(mailer.Log.GetMemoryLog()); mailer.Log.Clear(); mailer.Log.Format = LogFormatOptions.AddDate; mailer.Noop(); Console.WriteLine("Format is AddDate"); Console.WriteLine(mailer.Log.GetMemoryLog()); mailer.Log.Clear(); mailer.Log.Format = LogFormatOptions.AddContextInfo | LogFormatOptions.AddDate; mailer.Disconnect(); Console.WriteLine("Format is AddContextInfo | AddDate"); Console.WriteLine(mailer.Log.GetMemoryLog()); } } // The output (the actual content will be different for your case). Format is None [18:55:15.26] [RECV] 220 smtp.domain.com: please say hello\r\n Format is AddContextInfo [18:55:15.30] [RECV] [0020] [SMTP-00................] 250-smtp.domain.com: EHLO NOTEBOOK1 accepted\r\n250 Format is AddDate [11/08/2005 18:55:15.31] [RECV] 250 OK\r\n Format is AddContextInfo | AddDate [11/08/2005 18:55:15.32] [RECV] [000A] [SMTP-00................] 221 smtp.domain.com: see you later\r\n
[Visual Basic] Imports System Imports MailBee Imports MailBee.SmtpMail Class Sample ' LogNewEntry event handler. Private Shared Sub OnLogNewEntry(ByVal sender As Object, ByVal e As LogNewEntryEventArgs) ' For readability, reduce the number of log entries displayed If e.NewEntry.MessageType <> LogMessageType.Recv Then e.NewEntry.AddThisEntry = False End If End Sub ' The actual code. Shared Sub Main(ByVal args As String()) Dim mailer As New Smtp mailer.SmtpServers.Add("smtp.domain.com") ' Enable logging the SMTP session into memory. mailer.Log.Enabled = True mailer.Log.MemoryLog = True ' Subscribe to the LogNewEntry event. AddHandler mailer.LogNewEntry, AddressOf OnLogNewEntry mailer.Log.Clear() mailer.Connect() Console.WriteLine("Format is None") Console.WriteLine(mailer.Log.GetMemoryLog()) mailer.Log.Clear() mailer.Log.Format = LogFormatOptions.AddContextInfo mailer.Hello() Console.WriteLine("Format is AddContextInfo") Console.WriteLine(mailer.Log.GetMemoryLog()) mailer.Log.Clear() mailer.Log.Format = LogFormatOptions.AddDate mailer.Noop() Console.WriteLine("Format is AddDate") Console.WriteLine(mailer.Log.GetMemoryLog()) mailer.Log.Clear() mailer.Log.Format = LogFormatOptions.AddContextInfo Or LogFormatOptions.AddDate mailer.Disconnect() Console.WriteLine("Format is AddContextInfo Or AddDate") Console.WriteLine(mailer.Log.GetMemoryLog()) End Sub End Class ' The output (the actual content will be different for your case). Format is None [18:55:15.26] [RECV] 220 smtp.domain.com: please say hello\r\n Format is AddContextInfo [18:55:15.30] [RECV] [0020] [SMTP-00................] 250-smtp.domain.com: EHLO NOTEBOOK1 accepted\r\n250 Format is AddDate [11/08/2005 18:55:15.31] [RECV] 250 OK\r\n Format is AddContextInfo | AddDate [11/08/2005 18:55:15.32] [RECV] [000A] [SMTP-00................] 221 smtp.domain.com: see you later\r\n
| Member Name | Description | Value |
|---|---|---|
| None | Use default formatting. | 0 |
| AddDate | Include the current date in the timestamp. | 1 |
| AddContextInfo | Include the information about the current thread ID and the current context (such as DNSQ (DNS Query), SMTP, POP3, SEND). Useful in multi-thread mode (when log messages, produced by different threads, overlap). | 2 |
| BinaryAsText | Disable base64 encoding of binary data (usually, in DNS MX lookup queries). | 4 |
Namespace: MailBee
Assembly: MailBee.NET (in MailBee.NET.dll)