Skip to content

Instantly share code, notes, and snippets.

@JamesSkemp
Last active June 7, 2018 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesSkemp/567b2af59f035282a8f44da4f5cab572 to your computer and use it in GitHub Desktop.
Save JamesSkemp/567b2af59f035282a8f44da4f5cab572 to your computer and use it in GitHub Desktop.
Example getting first 10 requests from today's IIS logs and saving to dated txt file

See https://stackoverflow.com/a/10945887/11912 for more information on the first two lines (today is being set just to help understand the date formatting).

If run 6/7/2018, it would check the IIS log at C:\inetpub\logs\LogFiles\W3SVC1\u_ex180607.log and save the output to _test180607.txt.

for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x
set today=%MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2%
logparser -i:iisw3c "select top 10 * into _test%MyDate:~2,2%%MyDate:~4,2%%MyDate:~6,2%.txt from C:\inetpub\logs\LogFiles\W3SVC1\u_ex%MyDate:~2,2%%MyDate:~4,2%%MyDate:~6,2%.log" -rtp:-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment