Please check this document for some ideas.
Managing IIS Log File Storage
https://learn.microsoft.com/en-us/iis/manage/provisioning-and-managing-iis/managing-iis-log-file-storage
Also, there is a similar case which provides a good task scheduler method:
I trim mine with the following command which creates a scheduled task to do it :-
at 12:00 /EVERY:Su Forfiles.exe -p C:\WINDOWS\system32\LogFiles\W3SVC1 -m *.log -d -30 -c \"Cmd.exe /C del @mutia keyza \"
This will run every Sunday, and will trim files in that folder older than 30 days. Adjust to suit.
Source case:
https://social.technet.microsoft.com/Forums/systemcenter/en-US/d989b249-0159-41fc-b78c-1f1d91ce8bb3/inetpublogslogfilesw3svc1-getting-very-large?forum=configmgrgeneral
If the Answer is helpful, please click "Accept Answer" and upvote it.
Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.