Pages

Showing posts with label Logging. Show all posts
Showing posts with label Logging. Show all posts

Friday, 18 September 2009

Delete Old log files using VB6

VB6 Snippet to delete old log files

Private Sub deleteOldFiles()

Dim sFileName As String
Dim sFileSplit() As String
Dim sFileSpec As String
Dim sDir As String
Dim iCount As Integer
Dim iCtr As Integer
Dim dCompDate As Date
Dim dFileDate As Date

On Error GoTo errHandler

sFileSpec = App.Path & "\logs\*.log"
sFileName = Dir(sFileSpec)

dCompDate = Format(Now, "mm/dd/yyyy")

Do
    If sFileName = "" Then Exit Do
        If InStr(sFileSpec, "\") > 0 Then
            sFileSplit = Split(sFileSpec, "\")
            iCount = UBound(sFileSplit) - 1
                For iCtr = 0 To iCount
                    sDir = sDir & sFileSplit(iCtr) & "\"
                Next
            sFileName = sDir & sFileName
        End If
        dFileDate = Format(FileDateTime(sFileName), "mm/dd/yyyy")
        If DateDiff("d", dFileDate, dCompDate) >= 3 Then
         'Get File Attributes
          If GetAttr(sFileName) = 33 Then
             SetAttr sFileName, 32
          End If
         Kill sFileName
        End If
    sFileName = Dir
    sDir = ""
Loop

Exit Sub

errHandler:

MsgBox Err.Number & ":" & Err.Description

End Sub

Write log using VB6

Function to write log file using Visual Basic 6

Private Sub writeLog(strMessage As String)

Dim hFile As Long
Dim sFolder As String
Dim sFile As String
Dim sDestination As String
Dim sLog As String

On Error GoTo errHandler

hFile = FreeFile()
sFolder = App.Path & "\logs"
sFile = sFolder & "\Softphone.log"

sLog = Format(Now(), "yyyy-mm-dd HH:nn:ss") & "." & Right(Format(Timer(), "0.000"), 3)
sLog = sLog & vbTab & strMessage

If lLineNumber > 60000 Then 'Approx 5 MB
    lLineNumber = 1
    sDestination = sFolder & "\Softphone_" & Format(Now(), "yyyymmdd_HHnnss") & ".log"
    FileCopy sFile, sDestination
    Kill sFile
Else
    lLineNumber = lLineNumber + 1
End If

Open sFile For Append As #hFile
    Print #hFile, sLog
Close hFile

Exit Sub

errHandler:

If Err.Number = 76 Then 'If folder not exists, create it
    MkDir sFolder
    Resume
End If
MsgBox Err.Number & ":" & Err.Description

End Sub

Wednesday, 29 October 2008

Network Logging in Genesys

How to configure network logging in Genesys ?

Network logging in Genesys is a multi-step process. First, the application sends the log record to Message Server. Message server sends record to update in DB.

1. Create Log Database 

2  Initialize the database using the scripts in Message Server installation folder

3. In Message Server, add connection to LogDAP

4. In Message Server, set property 'messages\db_storage' as "true"

5. From any application object (like T-Server), add connection to the Message Server

Please note that log level should be set to network for any centralized logging. 

It is simple, isn't it?