FolderRisk: Caution
logs\LogFiles C:\inetpub\logs\LogFiles
Default location of IIS access logs (one subfolder per site, dated .log files); purge or archive them regularly.
What it’s for
IIS writes its request logs here: %SystemDrive%\inetpub\logs\LogFiles is the default logging directory. It appears as soon as IIS is installed, on Windows Server as well as on a client machine where the feature is turned on.
What it contains
- One subfolder per site:
W3SVC<site ID>(for exampleW3SVC1), andFTPSVC<ID>for FTP sites. .logfiles in W3C extended format (u_ex<yymmdd>.log), split by the rollover period you chose: hourly, daily, weekly or monthly.- For each request: date, time, client address, method, URI, status code, duration. W3C timestamps are in UTC, so expect an offset from the server’s local time.
- Not the HTTP.sys errors (
HTTPERR), which are inC:\Windows\System32\LogFiles.
Risks and best practices
- IIS never purges these logs, so on a busy server the system volume eventually fills up. Schedule deletion beyond a given age (Microsoft documents a script for it), keeping whatever retention your security policy or regulations require.
- Move the directory to another volume from IIS (site > Logging > Directory) rather than replacing the folder.
- Do not delete today’s file: the service holds it open.
- For large volumes, analyze with Log Parser or a monitoring tool rather than Notepad.
Useful commands
# Site IDs and names, so you know which W3SVC<id> folder is which& "$env:windir\system32\inetsrv\appcmd.exe" list site
# Log volume per site folderGet-ChildItem "$env:SystemDrive\inetpub\logs\LogFiles" -Directory | ForEach-Object { [pscustomobject]@{ Site = $_.Name; MB = [math]::Round((Get-ChildItem $_.FullName -Recurse -File | Measure-Object Length -Sum).Sum / 1MB, 1) } }
# Last lines of a site's logGet-ChildItem "$env:SystemDrive\inetpub\logs\LogFiles\W3SVC1" -Filter *.log | Sort-Object LastWriteTime | Select-Object -Last 1 | Get-Content -Tail 20
# Delete logs older than 30 days (as administrator; remove -WhatIf to run)Get-ChildItem "$env:SystemDrive\inetpub\logs\LogFiles" -Recurse -Filter *.log | Where-Object LastWriteTime -lt (Get-Date).AddDays(-30) | Remove-Item -WhatIf