[ComImportAttribute()][GuidAttribute("00210206-B1BA-11CE-ABC6-F5B2E79D9E3F")][InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType)][TypeLibTypeAttribute(1)]public interface ILtmsLogHandler
Public Interface ILtmsLogHandler public interface class ILtmsLogHandler Once the application has defined its own log handler it can pass a pointer to its ILtmsLogHandler interface using the ILogHandler property.
The server will call the application, and log events through the assigned log handler interface.
using Leadtools;using Leadtools.MediaStreaming;enum W3CLOG{date = 0x00000001,time = 0x00000002,c_ip = 0x00000004,cs_username = 0x00000008,s_sitename = 0x00000010,s_computername = 0x00000020,s_ip = 0x00000040,s_port = 0x00000080,cs_method = 0x00000100,cs_uri_stem = 0x00000200,cs_uri_query = 0x00000400,sc_status = 0x00000800,sc_win32_status = 0x00001000,sc_bytes = 0x00002000,cs_bytes = 0x00004000,time_taken = 0x00008000,cs_version = 0x00010000,cs_host = 0x00020000,cs_user_agent = 0x00040000,cs_cookie = 0x00080000,cs_referer = 0x00100000,sc_substatus = 0x00200000,};public class CW3CLogHandler : ILtmsLogHandler{bool m_enable;int m_fields;bool m_localtime;DateTime m_dtfile;string m_software;string m_folder;string m_prefix;StreamWriter m_sw;public CW3CLogHandler(string prefix, string software, bool enable, string folder, int fields, bool localtime){m_prefix = prefix;m_software = software;m_enable = enable;m_folder = folder;m_fields = fields;m_localtime = localtime;}~CW3CLogHandler(){}void WriteString(string str){m_sw.Write(str);}DateTime GetTime(double dTime){DateTime dt = DateTime.FromOADate(dTime);if (m_localtime)return dt.ToLocalTime();return dt;}string GetLogPath(double timestamp){DateTime dt = GetTime(timestamp);string strFullPath;try{PathResolver resolver = new PathResolver();strFullPath = resolver.Resolve(m_folder);}catch{return "";}strFullPath += "\\";strFullPath += m_prefix;if (!m_localtime){strFullPath += dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") + "UTC.log";}else{strFullPath += dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") + ".log";}return strFullPath;}public void LoadConfig(Server server){bool enable = m_enable;bool localtime = m_localtime;string folder = m_folder;int fields = m_fields;bool dirty = false;ApplicationProperties AppProps = server.GetApplicationProperties();try{enable = AppProps.GetBoolean("LogEnable");}catch{AppProps.AddBoolean("LogEnable", enable);dirty = true;}try{localtime = AppProps.GetBoolean("LogLocalTime");}catch{AppProps.AddBoolean("LogLocalTime", localtime);dirty = true;}try{folder = AppProps.GetString("LogFolder");}catch{AppProps.AddString("LogFolder", folder);dirty = true;}try{fields = AppProps.GetInteger("LogFields");}catch{AppProps.AddInteger("LogFields", fields);dirty = true;}if (dirty)server.SetApplicationProperties(AppProps);// if anything has changed then we need to close the current fileif (!enable && (string.Compare(m_folder, folder, true) != 0) || fields != m_fields || m_localtime != localtime){if (m_sw != null)m_sw.Close();}m_folder = folder;m_localtime = localtime;m_enable = enable;m_fields = fields;}bool CreateLog(double timestamp){if (m_sw != null)m_sw.Close();if (!m_enable)return false;try{m_sw = File.CreateText(GetLogPath(timestamp));}catch{return false;}m_dtfile = GetTime(timestamp);string s;s = "#Software: " + m_software + "\r\n";WriteString(s);WriteString("#Version: 1.0\r\n");DateTime dt = GetTime(timestamp);s = "#Date: " + dt.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n";WriteString(s);s = "#Fields:";if ((m_fields & (int)W3CLOG.date) == (int)W3CLOG.date){s += " date";}if ((m_fields & (int)W3CLOG.time) == (int)W3CLOG.time){s += " time";}if ((m_fields & (int)W3CLOG.s_sitename) == (int)W3CLOG.s_sitename){s += " s-sitename";}if ((m_fields & (int)W3CLOG.s_computername) == (int)W3CLOG.s_computername){s += " s-computername";}if ((m_fields & (int)W3CLOG.s_ip) == (int)W3CLOG.s_ip){s += " s-ip";}if ((m_fields & (int)W3CLOG.cs_method) == (int)W3CLOG.cs_method){s += " cs-method";}if ((m_fields & (int)W3CLOG.cs_uri_stem) == (int)W3CLOG.cs_uri_stem){s += " cs-uri-stem";}if ((m_fields & (int)W3CLOG.cs_uri_query) == (int)W3CLOG.cs_uri_query){s += " cs-uri-query";}if ((m_fields & (int)W3CLOG.s_port) == (int)W3CLOG.s_port){s += " s-port";}if ((m_fields & (int)W3CLOG.cs_username) == (int)W3CLOG.cs_username){s += " cs-username";}if ((m_fields & (int)W3CLOG.c_ip) == (int)W3CLOG.c_ip){s += " c-ip";}if ((m_fields & (int)W3CLOG.cs_version) == (int)W3CLOG.cs_version){s += " cs-version";}if ((m_fields & (int)W3CLOG.cs_user_agent) == (int)W3CLOG.cs_user_agent){s += " cs(User-Agent)";}if ((m_fields & (int)W3CLOG.cs_cookie) == (int)W3CLOG.cs_cookie){s += " cs(Cookie)";}if ((m_fields & (int)W3CLOG.cs_referer) == (int)W3CLOG.cs_referer){s += " cs(Referer)";}if ((m_fields & (int)W3CLOG.cs_host) == (int)W3CLOG.cs_host){s += " cs-host";}if ((m_fields & (int)W3CLOG.sc_status) == (int)W3CLOG.sc_status){s += " sc-status";}if ((m_fields & (int)W3CLOG.sc_substatus) == (int)W3CLOG.sc_substatus){s += " sc-substatus";}if ((m_fields & (int)W3CLOG.sc_win32_status) == (int)W3CLOG.sc_win32_status){s += " sc-win32-status";}if ((m_fields & (int)W3CLOG.sc_bytes) == (int)W3CLOG.sc_bytes){s += " sc-bytes";}if ((m_fields & (int)W3CLOG.cs_bytes) == (int)W3CLOG.cs_bytes){s += " cs-bytes";}if ((m_fields & (int)W3CLOG.time_taken) == (int)W3CLOG.time_taken){s += " time-taken";}s += "\r\n";WriteString(s);m_sw.Flush();return true;}string escape(string s){string t = "";foreach (char c in s){if (!char.IsControl(c) && !char.IsWhiteSpace(c))t += c;elset += "+";}return t;}public void InitializeLog(double timestamp){CreateLog(timestamp);}public void TerminateLog(){if (m_sw != null)m_sw.Close();}public void LogInformation(ILtmsLogInformation info){string s = "";if (!m_enable)return;// check if we need to roll to a new file{DateTime dt = GetTime(info.TimeStamp);if (m_sw == null || dt.Day != m_dtfile.Day || dt.Month != m_dtfile.Month || dt.Year != m_dtfile.Year){if (!CreateLog(info.TimeStamp))return;}}if ((m_fields & (int)W3CLOG.date) == (int)W3CLOG.date){DateTime dt = GetTime(info.TimeStamp);if (s.Length > 0)s += " ";s += dt.ToString("yyyy-MM-dd");}if ((m_fields & (int)W3CLOG.time) == (int)W3CLOG.time){DateTime dt = GetTime(info.TimeStamp);if (s.Length > 0)s += " ";s += dt.ToString("HH:mm:ss");}if ((m_fields & (int)W3CLOG.s_sitename) == (int)W3CLOG.s_sitename){string str = info.SiteName;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.s_computername) == (int)W3CLOG.s_computername){string str = info.ComputerName;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.s_ip) == (int)W3CLOG.s_ip){string str = info.ServerIP;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_method) == (int)W3CLOG.cs_method){string str = info.Method;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_uri_stem) == (int)W3CLOG.cs_uri_stem){string str = info.URIStem;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_uri_query) == (int)W3CLOG.cs_uri_query){string str = info.URIQuery;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.s_port) == (int)W3CLOG.s_port){int n = info.ServerPort;if (s.Length > 0)s += " ";s += n.ToString();}if ((m_fields & (int)W3CLOG.cs_username) == (int)W3CLOG.cs_username){string str = info.UserName;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.c_ip) == (int)W3CLOG.c_ip){string str = info.ClientIP;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_version) == (int)W3CLOG.cs_version){string str = info.ProtocolVersion;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_user_agent) == (int)W3CLOG.cs_user_agent){string str = info.UserAgent;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_cookie) == (int)W3CLOG.cs_cookie){string str = info.Cookie;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_referer) == (int)W3CLOG.cs_referer){string str = info.Referrer;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.cs_host) == (int)W3CLOG.cs_host){string str = info.Host;if (s.Length > 0)s += " ";if (str.Length == 0)s += "-";elses += escape(str);}if ((m_fields & (int)W3CLOG.sc_status) == (int)W3CLOG.sc_status){int n = info.Status;if (s.Length > 0)s += " ";s += n.ToString();}if ((m_fields & (int)W3CLOG.sc_substatus) == (int)W3CLOG.sc_substatus){int n = info.ProtocolSubStatus;if (s.Length > 0)s += " ";s += n.ToString();}if ((m_fields & (int)W3CLOG.sc_win32_status) == (int)W3CLOG.sc_win32_status){int n = info.Win32Status;if (s.Length > 0)s += " ";s += n.ToString();}if ((m_fields & (int)W3CLOG.sc_bytes) == (int)W3CLOG.sc_bytes){int n = info.BytesSent;if (s.Length > 0)s += " ";if (n < 0)s += "-";elses += n.ToString();}if ((m_fields & (int)W3CLOG.cs_bytes) == (int)W3CLOG.cs_bytes){int n = info.BytesReceived;if (s.Length > 0)s += " ";if (n < 0)s += "-";elses += n.ToString();}if ((m_fields & (int)W3CLOG.time_taken) == (int)W3CLOG.time_taken){int n = info.TimeTaken;if (s.Length > 0)s += " ";if (n < 0)s += "-";elses += n.ToString();}s += "\r\n";WriteString(s);m_sw.Flush();}}public Server _server = null;public bool _result = false;public void W3CLogHandlerExample(){try{State enumState;CW3CLogHandler _loghandler;// create an instance of the server object_server = new Leadtools.MediaStreaming.Server();// create the log handler_loghandler = new CW3CLogHandler("ltmsServer_", "LEADTOOLS Media Streaming Server", true, "%ltmsLogFolder%", 0, false);// set the log handler_server.ILogHandler = _loghandler;{// for demonstration, compare the interface we just setILtmsLogHandler ihandler = null;ihandler = _server.ILogHandler;if (ihandler != (ILtmsLogHandler)_loghandler){_result = false;return;}}// load the config file located in the config subfolder under the executable folder// or comment this section out to run with the server's default settings_server.ImportConfigFile("%ltmsConfigFolder%\\LeadtoolsMediaStreamingServer.xml");// start the server_server.Start();// confirm the running state for demonstration purposesenumState = _server.State;if (enumState == State.Started){// display a message that the server is running and wait for OKMessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information);}// stop the server_server.Stop();// remove the log handler_server.ILogHandler = null;_result = true;}catch (Exception){_result = false;}}
Imports LeadtoolsImports Leadtools.MediaStreamingPrivate Enum W3CLOG[date] = &H1time = &H2c_ip = &H4cs_username = &H8s_sitename = &H10s_computername = &H20s_ip = &H40s_port = &H80cs_method = &H100cs_uri_stem = &H200cs_uri_query = &H400sc_status = &H800sc_win32_status = &H1000sc_bytes = &H2000cs_bytes = &H4000time_taken = &H8000cs_version = &H10000cs_host = &H20000cs_user_agent = &H40000cs_cookie = &H80000cs_referer = &H100000sc_substatus = &H200000End EnumPublic Class CW3CLogHandler : Implements ILtmsLogHandlerPrivate m_enable As BooleanPrivate m_fields As IntegerPrivate m_localtime As BooleanPrivate m_dtfile As DateTimePrivate m_software As StringPrivate m_folder As StringPrivate m_prefix As StringPrivate m_sw As StreamWriterPublic Sub New(ByVal prefix As String, ByVal software As String, ByVal enable As Boolean, ByVal folder As String, ByVal fields As Integer, ByVal localtime As Boolean)m_prefix = prefixm_software = softwarem_enable = enablem_folder = folderm_fields = fieldsm_localtime = localtimeEnd SubProtected Overrides Sub Finalize()End SubPrivate Sub WriteString(ByVal str As String)m_sw.Write(str)End SubPrivate Function GetTime(ByVal dTime As Double) As DateTimeDim dt As DateTime = DateTime.FromOADate(dTime)If m_localtime ThenReturn dt.ToLocalTime()End IfReturn dtEnd FunctionPrivate Function GetLogPath(ByVal timestamp As Double) As StringDim dt As DateTime = GetTime(timestamp)Dim strFullPath As StringTryDim resolver As PathResolver = New PathResolver()strFullPath = resolver.Resolve(m_folder)CatchReturn ""End TrystrFullPath &= "\"strFullPath &= m_prefixIf (Not m_localtime) ThenstrFullPath &= dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") & "UTC.log"ElsestrFullPath &= dt.ToString("y-MM-dd-HH-mm-ss").Replace("-", "") & ".log"End IfReturn strFullPathEnd FunctionPublic Sub LoadConfig(ByVal server As Server)Dim enable As Boolean = m_enableDim localtime As Boolean = m_localtimeDim folder As String = m_folderDim fields As Integer = m_fieldsDim dirty As Boolean = FalseDim AppProps As ApplicationProperties = server.GetApplicationProperties()Tryenable = AppProps.GetBoolean("LogEnable")CatchAppProps.AddBoolean("LogEnable", enable)dirty = TrueEnd TryTrylocaltime = AppProps.GetBoolean("LogLocalTime")CatchAppProps.AddBoolean("LogLocalTime", localtime)dirty = TrueEnd TryTryfolder = AppProps.GetString("LogFolder")CatchAppProps.AddString("LogFolder", folder)dirty = TrueEnd TryTryfields = AppProps.GetInteger("LogFields")CatchAppProps.AddInteger("LogFields", fields)dirty = TrueEnd TryIf dirty Thenserver.SetApplicationProperties(AppProps)End If' if anything has changed then we need to close the current fileIf (Not enable) AndAlso (String.Compare(m_folder, folder, True) <> 0) OrElse fields <> m_fields OrElse m_localtime <> localtime ThenIf Not m_sw Is Nothing Thenm_sw.Close()End IfEnd Ifm_folder = folderm_localtime = localtimem_enable = enablem_fields = fieldsEnd SubPrivate Function CreateLog(ByVal timestamp As Double) As BooleanIf Not m_sw Is Nothing Thenm_sw.Close()End IfIf (Not m_enable) ThenReturn FalseEnd IfTrym_sw = File.CreateText(GetLogPath(timestamp))CatchReturn FalseEnd Trym_dtfile = GetTime(timestamp)Dim s As Strings = "#Software: " & m_software & Constants.vbCrLfWriteString(s)WriteString("#Version: 1.0" & Constants.vbCrLf)Dim dt As DateTime = GetTime(timestamp)s = "#Date: " & dt.ToString("yyyy-MM-dd HH:mm:ss") & Constants.vbCrLfWriteString(s)s = "#Fields:"If (m_fields And CInt(W3CLOG.date)) = CInt(W3CLOG.date) Thens &= " date"End IfIf (m_fields And CInt(W3CLOG.time)) = CInt(W3CLOG.time) Thens &= " time"End IfIf (m_fields And CInt(W3CLOG.s_sitename)) = CInt(W3CLOG.s_sitename) Thens &= " s-sitename"End IfIf (m_fields And CInt(W3CLOG.s_computername)) = CInt(W3CLOG.s_computername) Thens &= " s-computername"End IfIf (m_fields And CInt(W3CLOG.s_ip)) = CInt(W3CLOG.s_ip) Thens &= " s-ip"End IfIf (m_fields And CInt(W3CLOG.cs_method)) = CInt(W3CLOG.cs_method) Thens &= " cs-method"End IfIf (m_fields And CInt(W3CLOG.cs_uri_stem)) = CInt(W3CLOG.cs_uri_stem) Thens &= " cs-uri-stem"End IfIf (m_fields And CInt(W3CLOG.cs_uri_query)) = CInt(W3CLOG.cs_uri_query) Thens &= " cs-uri-query"End IfIf (m_fields And CInt(W3CLOG.s_port)) = CInt(W3CLOG.s_port) Thens &= " s-port"End IfIf (m_fields And CInt(W3CLOG.cs_username)) = CInt(W3CLOG.cs_username) Thens &= " cs-username"End IfIf (m_fields And CInt(W3CLOG.c_ip)) = CInt(W3CLOG.c_ip) Thens &= " c-ip"End IfIf (m_fields And CInt(W3CLOG.cs_version)) = CInt(W3CLOG.cs_version) Thens &= " cs-version"End IfIf (m_fields And CInt(W3CLOG.cs_user_agent)) = CInt(W3CLOG.cs_user_agent) Thens &= " cs(User-Agent)"End IfIf (m_fields And CInt(W3CLOG.cs_cookie)) = CInt(W3CLOG.cs_cookie) Thens &= " cs(Cookie)"End IfIf (m_fields And CInt(W3CLOG.cs_referer)) = CInt(W3CLOG.cs_referer) Thens &= " cs(Referer)"End IfIf (m_fields And CInt(W3CLOG.cs_host)) = CInt(W3CLOG.cs_host) Thens &= " cs-host"End IfIf (m_fields And CInt(W3CLOG.sc_status)) = CInt(W3CLOG.sc_status) Thens &= " sc-status"End IfIf (m_fields And CInt(W3CLOG.sc_substatus)) = CInt(W3CLOG.sc_substatus) Thens &= " sc-substatus"End IfIf (m_fields And CInt(W3CLOG.sc_win32_status)) = CInt(W3CLOG.sc_win32_status) Thens &= " sc-win32-status"End IfIf (m_fields And CInt(W3CLOG.sc_bytes)) = CInt(W3CLOG.sc_bytes) Thens &= " sc-bytes"End IfIf (m_fields And CInt(W3CLOG.cs_bytes)) = CInt(W3CLOG.cs_bytes) Thens &= " cs-bytes"End IfIf (m_fields And CInt(W3CLOG.time_taken)) = CInt(W3CLOG.time_taken) Thens &= " time-taken"End Ifs &= Constants.vbCrLfWriteString(s)m_sw.Flush()Return TrueEnd FunctionPrivate Function escape(ByVal s As String) As StringDim t As String = ""For Each c As Char In sIf (Not Char.IsControl(c)) AndAlso (Not Char.IsWhiteSpace(c)) Thent &= cElset &= "+"End IfNext cReturn tEnd FunctionPublic Sub InitializeLog(ByVal timestamp As Double) Implements ILtmsLogHandler.InitializeLogCreateLog(timestamp)End SubPublic Sub TerminateLog() Implements ILtmsLogHandler.TerminateLogIf Not m_sw Is Nothing Thenm_sw.Close()End IfEnd SubPublic Sub LogInformation(ByVal info As ILtmsLogInformation) Implements ILtmsLogHandler.LogInformationDim s As String = ""If (Not m_enable) ThenReturnEnd If' check if we need to roll to a new fileDim dt As DateTime = GetTime(info.TimeStamp)If m_sw Is Nothing OrElse dt.Day <> m_dtfile.Day OrElse dt.Month <> m_dtfile.Month OrElse dt.Year <> m_dtfile.Year ThenIf (Not CreateLog(info.TimeStamp)) ThenReturnEnd IfEnd IfIf (m_fields And CInt(W3CLOG.date)) = CInt(W3CLOG.date) ThenDim dtDate As DateTime = GetTime(info.TimeStamp)If s.Length > 0 Thens &= " "End Ifs &= dtDate.ToString("yyyy-MM-dd")End IfIf (m_fields And CInt(W3CLOG.time)) = CInt(W3CLOG.time) ThenDim dtTime As DateTime = GetTime(info.TimeStamp)If s.Length > 0 Thens &= " "End Ifs &= dtTime.ToString("HH:mm:ss")End IfIf (m_fields And CInt(W3CLOG.s_sitename)) = CInt(W3CLOG.s_sitename) ThenDim str As String = info.SiteNameIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.s_computername)) = CInt(W3CLOG.s_computername) ThenDim str As String = info.ComputerNameIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.s_ip)) = CInt(W3CLOG.s_ip) ThenDim str As String = info.ServerIPIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_method)) = CInt(W3CLOG.cs_method) ThenDim str As String = info.MethodIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_uri_stem)) = CInt(W3CLOG.cs_uri_stem) ThenDim str As String = info.URIStemIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_uri_query)) = CInt(W3CLOG.cs_uri_query) ThenDim str As String = info.URIQueryIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.s_port)) = CInt(W3CLOG.s_port) ThenDim n As Integer = info.ServerPortIf s.Length > 0 Thens &= " "End Ifs &= n.ToString()End IfIf (m_fields And CInt(W3CLOG.cs_username)) = CInt(W3CLOG.cs_username) ThenDim str As String = info.UserNameIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.c_ip)) = CInt(W3CLOG.c_ip) ThenDim str As String = info.ClientIPIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_version)) = CInt(W3CLOG.cs_version) ThenDim str As String = info.ProtocolVersionIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_user_agent)) = CInt(W3CLOG.cs_user_agent) ThenDim str As String = info.UserAgentIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_cookie)) = CInt(W3CLOG.cs_cookie) ThenDim str As String = info.CookieIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_referer)) = CInt(W3CLOG.cs_referer) ThenDim str As String = info.ReferrerIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_host)) = CInt(W3CLOG.cs_host) ThenDim str As String = info.HostIf s.Length > 0 Thens &= " "End IfIf str.Length = 0 Thens &= "-"Elses &= escape(str)End IfEnd IfIf (m_fields And CInt(W3CLOG.sc_status)) = CInt(W3CLOG.sc_status) ThenDim n As Integer = info.StatusIf s.Length > 0 Thens &= " "End Ifs &= n.ToString()End IfIf (m_fields And CInt(W3CLOG.sc_substatus)) = CInt(W3CLOG.sc_substatus) ThenDim n As Integer = info.ProtocolSubStatusIf s.Length > 0 Thens &= " "End Ifs &= n.ToString()End IfIf (m_fields And CInt(W3CLOG.sc_win32_status)) = CInt(W3CLOG.sc_win32_status) ThenDim n As Integer = info.Win32StatusIf s.Length > 0 Thens &= " "End Ifs &= n.ToString()End IfIf (m_fields And CInt(W3CLOG.sc_bytes)) = CInt(W3CLOG.sc_bytes) ThenDim n As Integer = info.BytesSentIf s.Length > 0 Thens &= " "End IfIf n < 0 Thens &= "-"Elses &= n.ToString()End IfEnd IfIf (m_fields And CInt(W3CLOG.cs_bytes)) = CInt(W3CLOG.cs_bytes) ThenDim n As Integer = info.BytesReceivedIf s.Length > 0 Thens &= " "End IfIf n < 0 Thens &= "-"Elses &= n.ToString()End IfEnd IfIf (m_fields And CInt(W3CLOG.time_taken)) = CInt(W3CLOG.time_taken) ThenDim n As Integer = info.TimeTakenIf s.Length > 0 Thens &= " "End IfIf n < 0 Thens &= "-"Elses &= n.ToString()End IfEnd Ifs &= Constants.vbCrLfWriteString(s)m_sw.Flush()End SubEnd ClassPublic _server As Server = NothingPublic _result As Boolean = FalsePublic Sub W3CLogHandlerExample()TryDim enumState As StateDim _loghandler As CW3CLogHandler' create an instance of the server object_server = New Leadtools.MediaStreaming.Server()' create the log handler_loghandler = New CW3CLogHandler("ltmsServer_", "LEADTOOLS Media Streaming Server", True, "%ltmsLogFolder%", 0, False)' set the log handler_server.ILogHandler = _loghandler' for demonstration, compare the interface we just setDim ihandler As ILtmsLogHandler = Nothingihandler = _server.ILogHandlerIf Not ihandler Is CType(_loghandler, ILtmsLogHandler) Then_result = FalseReturnEnd If' load the config file located in the config subfolder under the executable folder' or comment this section out to run with the server's default settings_server.ImportConfigFile("%ltmsConfigFolder%\LeadtoolsMediaStreamingServer.xml")' start the server_server.Start()' confirm the running state for demonstration purposesenumState = _server.StateIf enumState = State.Started Then' display a message that the server is running and wait for OKMessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information)End If' stop the server_server.Stop()' remove the log handler_server.ILogHandler = Nothing_result = TrueCatch e1 As Exception_result = FalseEnd TryEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
