imAbhi imAbhi - 1 year ago 92
ASP.NET (C#) Question

IIS 7 Log Files Auto Delete?

Is there any feature in IIS 7 that automatically deletes the logs files older than a specified amt of days?

I am aware that this can be accomplished by writing a script(and run it weekly) or a windows service, but i was wondering if there is any inbuilt feature or something that does that.

Also, Currently we turned logging off as it is stacking up a large amount of space. Will that be a problem?

Answer Source

You can create a task that runs daily using Administrative Tools > Task Scheduler.

Set your task to run the following command:

forfiles /p "C:\inetpub\logs\LogFiles" /s /m *.* /c "cmd /c Del @path" /d -7

This command is for IIS7, and it deletes all the log files that are one week or older.

You can adjust the number of days by changing the /d arg value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download