Web server logs with MSSQL

  • I often get asked how to deal with web server logs.
  • How can they be converted and stored into an SQL database?
  • How do we read the web logs, so we can analyze them...
  • Microsoft has created this great gem: logparser. Logparser is available for free at Microsoft LogParser.

Logparser

Logparser provides access and convert from/to:

  1. Text-based data such as log files, XML files and CSV files from Apache or IIS
  2. Windows Event Log
  3. Windows Registry
  4. Exchange logs
  5. Active Directory logs

LogParser examples

Querying data with LogParser

  1. LogParser.exe -i:NCSA  "select logfilename, logrow, remotehostname, remotelogname, username, datetime, request, statuscode, bytessent, referer, user-agent, cookie from \sql\access_log.20070908011201" -o:datagrid
LogParser
Querying data with LogParser
  • LogParser uses SQL syntax for querying the logs.