LogFormatOptions Enumeration |
Provides flags which can be used to change formatting of log messages produced
by MailBee.
Namespace: MailBeeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax [FlagsAttribute]
public enum LogFormatOptions
<FlagsAttribute>
Public Enumeration LogFormatOptions
Members
| Member name | Value | Description |
---|
| None | 0 |
Use default formatting.
|
| AddDate | 1 |
Include the current date in the timestamp.
|
| AddContextInfo | 2 |
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).
|
| BinaryAsText | 4 |
Disable base64 encoding of binary data (usually, in DNS MX lookup queries).
|
Examples This sample demonstrates the effect of different
LogFormatOptions flags.
Note |
---|
The actual values can be different in your case. |
using System;
using MailBee;
using MailBee.SmtpMail;
class Sample
{
private static void OnLogNewEntry(object sender, LogNewEntryEventArgs e)
{
if (e.NewEntry.MessageType != LogMessageType.Recv)
{
e.NewEntry.AddThisEntry = false;
}
}
static void Main(string[] args)
{
Smtp mailer = new Smtp();
mailer.SmtpServers.Add("smtp.domain.com");
mailer.Log.Enabled = true;
mailer.Log.MemoryLog = true;
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());
}
}
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
Imports System
Imports MailBee
Imports MailBee.SmtpMail
Class Sample
Private Shared Sub OnLogNewEntry(ByVal sender As Object, ByVal e As LogNewEntryEventArgs)
If e.NewEntry.MessageType <> LogMessageType.Recv Then
e.NewEntry.AddThisEntry = False
End If
End Sub
Shared Sub Main(ByVal args As String())
Dim mailer As New Smtp
mailer.SmtpServers.Add("smtp.domain.com")
mailer.Log.Enabled = True
mailer.Log.MemoryLog = True
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
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
See Also