Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Using MS Log Parser for IIS LogsUsing MS Log Parser for IIS Logs
Previous
 
Next
New Post
9/12/2012 3:59 PM
 

Wasn't sure how many have been using Log Parser for their IIS logs, but thought I would write this up quickly so if you wish to import your IIS logs into a database, you can.  Works quite well; especially when you're trying to track down a hack attempt, DNN error, etc.

Download Log Parser and install this onto your machine.  After installing this, be sure to add it to your system path so that you can run it from a command prompt from whatever folder you're currently in.  E.g.  "C:\Program Files (x86)\Log Parser 2.2;"

Once you've installed this and added it to your system path, you can simply open a command prompt and enter the following:

LogParser "SELECT * INTO %TABLE% FROM \\%webserver%\c$\inetpub\logs\LogFiles\W3SVC1\u_ex120911*.log, \\%webserver%\c$\inetpub\logs\LogFiles\W3SVC1\u_ex120912*.log" -i:W3C -o:SQL -server:%DBSERVER% -database:%DATABASE% -driver:"SQL Server" -username:%SQLUSER% -password:%PASSWORD% -createTable:ON -clearTable:ON


%TABLE% - enter the table name which is going to hold your log information.
%webserver% - enter the name of your webserver which you want the logs to be inserted from. in the above example, I'm just going directly to the logfiles folder going to admin C$.
%DBSERVER% - enter the name or IP address of the SQL server which is hosting the logs database.
%DATABASE% - enter the name of the database which you want the logs inserted into
%SQLUSER% - enter the name of the SQL user used by Log Parser to insert the information. Obviously needs the proper permissions.
%PASSWORD% - the SQL users password.

-createTable:ON - this will automatically create the %TABLE% when log parser is run.
-clearTable:ON - this will truncate all the existing data within the %TABLE% when log parser is run.

If you look at the above example, you'll notice that it's going to import all the entries from the 11th (u_ex120911*.log) and the 12th (u_ex120912*.log).  Depending on how many entries there are etc., depends on how long it takes to run.  This took upwards for 10-15 minutes to complete for about a full week of logs.  I have Task Scheduler configured to run this every morning to import the prior nights logs.

Another example I use is the one below.  This will parse the logs and return to you all the IP addresses which have hit all URL's 20 or more times.  This is good for tracking down illegal crawlers, spiders, etc.

LogParser "SELECT DISTINCT date, cs-uri-stem, c-ip, Count(*) AS Hits INTO %TABLE% FROM \\%webserver%\c$\inetpub\logs\LogFiles\W3SVC1\u_ex120911*.log, \\%webserver%\c$\inetpub\logs\LogFiles\W3SVC1\u_ex120912*.log GROUP BY date, c-ip, cs-uri-stem HAVING Hits>20 ORDER BY Hits Desc" -i:W3C -o:SQL -server:%DBSERVER% -database:%DATABASE% -driver:"SQL Server" -username:%SQLUSER% -password:%PASSWORD% -createTable:ON -clearTable:ON


 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Using MS Log Parser for IIS LogsUsing MS Log Parser for IIS Logs


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out