Dynamicweb 8 Documentation
Log(String,Exception,String,LogType,Boolean,LogElements) Method
Example 

Message to be logged.
Optional exception to be logged.
Subfolder in which the log file is placed. Base folder is: '/Files/System/Log/...'.
Toggles when to split the log.
Toggles whether to output extended property information.
Type of system elements to log.
Logs the message to the log file.
Syntax
'Declaration
 
Public Overloads Shared Sub Log( _ 
   ByVal message As String, _ 
   ByVal logException As Exception, _ 
   ByVal folder As String, _ 
   ByVal newLogFile As LogToFile.LogType, _ 
   ByVal useExtendedPropertyLogging As Boolean, _ 
   ByVal logElements As LogToFile.LogElements _ 
) 
public static void Log( 
   string message,
   Exception logException,
   string folder,
   LogToFile.LogType newLogFile,
   bool useExtendedPropertyLogging,
   LogToFile.LogElements logElements 
)

Parameters

message
Message to be logged.
logException
Optional exception to be logged.
folder
Subfolder in which the log file is placed. Base folder is: '/Files/System/Log/...'.
newLogFile
Toggles when to split the log.
useExtendedPropertyLogging
Toggles whether to output extended property information.
logElements
Type of system elements to log.
Example
Logging mail eventsLogging mail events
namespace Dynamicweb.Examples.CSharp
{
    class EmailHandlerSample
    {
        public void SendMail()
        {
            bool sendSucceded;

            using (var m = new System.Net.Mail.MailMessage())
            {
                m.Subject = "This is a test mail";
                m.From = new System.Net.Mail.MailAddress("noreply@dynamicweb-cms.com", "John Doe");
                m.To.Add("someone@gmail.com");
                m.IsBodyHtml = true;
                m.Body = "<h1>Hi John</h1>Here is your message.";
                m.BodyEncoding = System.Text.Encoding.UTF8;
                m.SubjectEncoding = System.Text.Encoding.UTF8;
                m.HeadersEncoding = System.Text.Encoding.UTF8;

                sendSucceded = EmailHandler.Send(m);
            }

            if (sendSucceded)
            {
                //Log to /Files/System/Log/MyMails
                Dynamicweb.LogToFile.Log("Mail succesfully sent", "/MyMails", LogToFile.LogType.ManyEntriesPerFile);
            }
            else
            {
                //Log to /Files/System/Log/MyMails
                Dynamicweb.LogToFile.Log("ERROR: Mail not sent", "/MyMails/Error", LogToFile.LogType.ManyEntriesPerFile);
            }

        }
    }
}
Public Class EmailHandlerSample
    Public Sub SendMail()
        Dim sendSucceded As Boolean

        Using m As New System.Net.Mail.MailMessage
            m.Subject = "This is a test mail"
            m.From = New System.Net.Mail.MailAddress("noreply@dynamicweb-cms.com", "John Doe")
            m.To.Add("someone@gmail.com")
            m.IsBodyHtml = True
            m.Body = "<h1>Hi John</h1>Here is your message."
            m.BodyEncoding = System.Text.Encoding.UTF8
            m.SubjectEncoding = System.Text.Encoding.UTF8
            m.HeadersEncoding = System.Text.Encoding.UTF8

            sendSucceded = EmailHandler.Send(m)
        End Using

        If sendSucceded Then
            'Log to /Files/System/Log/MyMails
            Global.Dynamicweb.LogToFile.Log("Mail succesfully sent", "/MyMails", LogToFile.LogType.ManyEntriesPerFile)
        Else
            'Log to /Files/System/Log/MyMails
            Global.Dynamicweb.LogToFile.Log("ERROR: Mail not sent", "/MyMails/Error", LogToFile.LogType.ManyEntriesPerFile)
        End If

    End Sub
End Class
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

LogToFile Class
LogToFile Members
Overload List

Send Feedback