Inherited an IIS server when I started a new job. The previous "admin" had no log management policy in place. I'm now staring at a 56GB .log file that was created by a piece of software running in the background. I'm looking for a way to cut the log down to the last 50MB dump and keep it that way. Any suggestions?

There are also 63GB of IIS logs, but those I can deal with.

  • Do you need the contents of the log? Why not move/archive it somewhere and let the application start a new log file? – joeqwerty Feb 8 '18 at 13:34
  • I don't want to have to worry about this anymore. If i start a new file, yes, it's going to be smaller, at first. Eventually it'll grow to what I have now. I'm looking for a more permanent solution without rewriting the logging part of the application. – UnS3eN Feb 8 '18 at 15:28
  • So use a scheduled task to move and rename the log file every x amount of time and let the program create a new one as @joeqwerty suggests. – JBaldridge Feb 8 '18 at 15:52

Thanks @jeiqwerty @JBaldrige.

Wrote a batch file that is now set up to run once a day:

move "%ROOT_FOLDER%\nettrace.log" "%ROOT_FOLDER%\history\nettrace.log"
ren "%%ROOT_FOLDER%\history\nettrace.log" "%ROOT_FOLDER%\history\nettrace-%date:/=-%.log"
forfiles -p "%ROOT_FOLDER%\history" -s -m *.* -d -2 -c "cmd /c del @file"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.