Add daily log rotation to api.asp
Issue: api.log was growing indefinitely with no rotation Impact: With 200+ PCs reporting daily, log file would grow to 2+ GB/year Fix: Changed logging to create daily log files - Old: logs/api.log (single file, grows forever) - New: logs/api-YYYY-MM-DD.log (one file per day) Example log files: - logs/api-2025-11-21.log - logs/api-2025-11-22.log - logs/api-2025-11-23.log Benefits: - Easier to troubleshoot (find logs by date) - Automatic separation (no manual log rotation needed) - Can delete old logs after N days - File sizes manageable (~6MB/day estimated) Cleanup Recommendation: Delete logs older than 30 days: forfiles /p "C:\inetpub\wwwroot\shopdb\logs" /s /m api-*.log /d -30 /c "cmd /c del @path" Or use Windows Task Scheduler to automate cleanup 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
5
api.asp
5
api.asp
@@ -1528,7 +1528,10 @@ Sub LogToFile(message)
|
||||
On Error Resume Next
|
||||
|
||||
Dim fso, logFile, logPath
|
||||
logPath = Server.MapPath("./logs/api.log")
|
||||
' Create daily log files: api-2025-11-21.log
|
||||
Dim logFileName
|
||||
logFileName = "api-" & Year(Now()) & "-" & Right("0" & Month(Now()), 2) & "-" & Right("0" & Day(Now()), 2) & ".log"
|
||||
logPath = Server.MapPath("./logs/" & logFileName)
|
||||
|
||||
Set fso = Server.CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user