Computer Tips - Apache: how can I have a log per day?

Date: 2020mar5
Product: Apache
OS: Windows
Keywords: httpd
Credit: Jeff

Q.  Apache: how can I have a log per day?

A.  Pipe to rotatelogs (a program bundled with Apache)

# CustomLog "logs/access.log" common CustomLog "|bin/rotatelogs.exe logs/access-%Y-%m-%d-%H_%M_%S.log 86400" combined
Then a PowerShell script to clean things up
# Delete all files older than 30 day(s) $Path = "C:\Program Files (x86)\Apache Software Foundation\Apache2.4\logs" $Daysback = "-30" $CurrentDate = Get-Date $DatetoDelete = $CurrentDate.AddDays($Daysback) Get-ChildItem $Path | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item