The Kiwi Logger .Net DLL (KLOG_NET.dll) is a multi-threaded .net DLL that has been designed specifically for use with VB.net, ASP.net or other .net languages (eg. C#).
Requirements: .Net Framework
Properties: RemoteAddress(strRemoteAddress As String)
RemotePort(lngRemotePort As Long)
FacilityName(strFacilityName As String)
FacilityNumber(lngFacilityNumber As Long)
LevelName(strLevelName As String)
LevelNumber(lngLevelNumber As Long)
PriorityNumber(lngPriorityNumber As Long)
MessageText(strMessageText As String)
UseRFC(blnUseRFC As Boolean)
UseUTF8(blnUseUTF8 As Boolean)
ErrorData(strError_Data As String)
Methods:
InitSocket(useTCP as Boolean) as Boolean
- Initializes the socket. Used to set the kind of data the socket will be sending.
- Called with one parameter: UseTCP = true/false, False=UDP protocol, True=TCP protocol
- InitSocket() Returns TRUE if the Socket type was set successful.
Connect() as Boolean
- Performs an asynchronous connection on an initialized socket.
- The callback delegate will fire the Connect() event when connected.
- Returns TRUE if Asynchronous connect has begun successfully.
SendMessage( Optional sRAddress As String, Optional lRPort As Long, _
Optional vFac As Variant, Optional vLev As Variant, _
Optional sMText As String, Optional bRFC As Boolean, _
Optional bUFT8 As Boolean ) as Boolean
- Performs an asynchronous send.
- The callback delegate will fire the SendComplete() event when sent.
Events:
Klog_Net.dll raises separate events which signal the completion of the callback delegate or worker thread.
The events are:
Connected()
- Used for TCP Protocol-Types, not necessary for UDP (A connection-less protocol)
- Indicates that the Connect() method has been successful.
SendComplete( bytesSent as Long )
- Signals the completion of a send process.
Exception( ex as Exception )
- Exposes any exception generated by callback delegates or in the DLL itself.
Examples:
Samples can be found in ../KLOGDLL_Net/Samples. There is one sample solution for ASP.net (KlogWeb) and one for VB.net (KLogWin).
KLOG_NET.dll can be found linked in the /bin directory of each sample, or unlinked in the ../KLOGDLL_NET directory.
The basic structure of a .net application that utilizes KLog_Net.dll is as follows:
' UDP SYSLOG SENDER
' ================
' Ensure that KLOG_NET.dll is added as a reference
' Create instance of KLOG_NET.SyslogSender
Dim SyslogSender as New KLOG_NET.SyslogSender
' Set the type of socket and then initialize that socket SyslogSender.InitSocket(false) ' USE UDP!
' Set the Remote Host
SyslogSender.RemoteAddress = "127.0.0.1" ' (Localhost)
SyslogSender.RemotePort = "514" ' Standard Syslog UDP port
' Set the message options
SyslogSender.FacilityNumber = 1
SyslogSender.LevelNumber = 1
SyslogSender.UseUTF8 = True ' Use UTF8 Encoding
' Set the message content
SyslogSender.MessageText = "Hello world"
' Send the message
SyslogSender.SendMessage()
' Shutdown and close the Socket
SyslogSender.Close()
SyslogSender = Nothing