Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:31:48+00:00 2026-05-23T10:31:48+00:00

Ok, so I have some IIS logs that I would like to parse with

  • 0

Ok, so I have some IIS logs that I would like to parse with Python (which I am fairly new to atm). A sample of IIS log looks like this:

#Software: Microsoft Internet Information Server 6.0 
#Version: 1.0 
#Date: 1998-11-19 22:48:39 
#Fields: date time c-ip cs-username s-ip cs-method cs-uri-stem cs-uri-query sc-status sc-bytes cs-bytes time-taken cs-version cs(User-Agent) cs(Cookie) cs(Referrer) 

1998-11-19 22:48:39 206.175.82.5 - 208.201.133.173 GET /global/images/navlineboards.gif - 200 540 324 157 HTTP/1.0 Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+95) USERID=CustomerA;+IMPID=01234 http://www.loganalyzer.net
1998-11-20 22:55:39 206.175.82.8 - 208.201.133.173 GET /global/something.pdf - 200 540 324 157 HTTP/1.0 Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+95) USERID=CustomerA;+IMPID=01234 http://www.loganalyzer.net

There are only 2 lines of log data here, where I have thousands per log.. So, this is just a short example.

From this logs I would like to extract data like – counts of client IP addresses that made the most connections, counts of files that were downloaded the most, number of URIs that were visited the most, etc… Basically what I want is to get some statistics… For example, as a result I would like to see something like this:

file download_count
example1.pdf 9
example2.pdf 6
example3.doc 2

or

IP file hits
192.168.1.5 /sample/example1.gif 8
192.168.1.9 /files/example2.gif 8

What I am not sure is how to approach this in a pythonic way. At first I thought I would split each line of the log and make a list out of it, and append each one to a bigger list (I see it as a 2d array). Then I got to the phase of extracting statistics from that big list, and now I think it would maybe be better to make a dictionary out of all that data and count stuff by dict keys and dict values? Is that a better approach than using lists? If I should better use lists, how should I approach it that way? What do I google, what do I look for?

So I am looking for ideas on how this is usually supposed to be done. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:31:49+00:00Added an answer on May 23, 2026 at 10:31 am

    assuming that skip_header(file) returns only the log lines from the file and that parse(line) extracts the (ip, path) from the line:

    from collections import defaultdict
    first = defaultdict(int)
    second = defaultdict(lambda: defaultdict(int))
    for line in skip_header(file):
        ip, path = parse(line)
        first[path] += 1
        second[ip][path] += 1
    

    for the first

    print "path count"
    for path, count in first.iteritems():
        print "%s %d" % (path, count)
    

    for second:

    print "ip path count"
    for ip,d in second.iteritems():
         for path, count in d.iteritems():
             print "%s %s %d" % (ip, path, count)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some static images in a folder on my IIS 6-based website that
I have some questions about IIS application pool configuration. I know that idleTimeout specifies
I'd like to write a script/batch that will bunch up my daily IIS logs
Background: I have a code of 64 in my IIS logs which I think
I have a script that parses IIS logs and at the moment it fetches
I have a wcf service that is hosted in IIS. This service launches some
I have some code that works on my IIS 5.1 dev box, but not
I have some rewrite rules that were working with a IIS rewrite tool for
I have some WCF services that are hosted by IIS with ASP.Net compatibility turned
i have some big xslt crashing iis (StackOverflowException) when loading an XslCompiledTransform while the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.