Today I wanted to find a way to flush the IIS FTP logs on-demand. The logs for IIS FTP flush to disk every 6 minutes, and the HTTP logs every 1 minute (or 64kb). This can make troubleshooting difficult when you don’t receive immediate access to the latest log data.
There is not a netsh or appcmd solution though, so the scripting or programming options are the way to do it. Actually, you can also flush the logs by restarting the Microsoft FTP Service (ftpsvc) but, as you would assume, it will impact currently active FTP sessions.
This blog post serves three purposes.
- It’s a reference pointing to Robert’s examples
- I’ll include how to do the same for the HTTP logs
- I’ll provide a PowerShell example which I based on Robert’s examples
1. The reference is mentioned above already, but to give me something useful to write in this paragraph, I’ll include it again. Programmatically Flushing FTP Logs.
2. For HTTP there is a method to flush the logs using netsh.
netsh http flush logbuffer
This will immediately flush the HTTP logs for all sites.
3. The FTP logs can be done from PowerShell too. Here’s a script which is the PowerShell equivalent of Robert’s examples. Just update $siteName, or pass it as a parameter to the script.
I hope one of these programming/scripting options come in handy for times when you want immediate access to the latest FTP log data.