LogFile_Add

Adds an entry to log file, if file is not exist, it will be created.
Filename is expected to be defined inside the function, currently using format of "log-yyyy-mm.txt" for monthly, "log-yyyy-mm-dd.txt" for daily log
Call can customize creation of monthly or daily
Monthly1_or_Daily2 is 1 for monthly, 2 for daily

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub LogFile_Add(LogEntry, Monthly1_or_Daily2)
' adds entry to log, 1 log file per day or per month
' Date is now, ip is automatic, filename already defined
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
FinN = "/Admin/Logs/Log-" & Year(Now()) & "-" & Right("00" & Month(Now()), 2) & ".txt"
If Monthly1_or_Daily2 = 2 Then _
FinN = "/Admin/Logs/Log-" & Year(Now()) & "-" & Right("00" & Month(Now()), 2) & "-" & Right("00" & Day(Now()), 2) & ".txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Server.MapPath(FiNn), ForAppending, True)
f.WriteLine Now() & " | " & LogEntry
End Sub

LogEntry, Monthly1_or_Daily2

Views 4,227

Downloads 1,400

CodeID
DB ID