how do I configure IIS to post logs to sql server?

Microsoft has courteously created an entire KB article called "How To Use SQL Server to Analyze Web Logs" which should answer your title question.

Yes it makes sense to store the logs in sql server if for no other reason than mitigating file corruption issues and also making backups of those files easier using SQL scheduler. The pros of using a SQL Server database are virtually self evident. Flat text files offer no data mining ability. Relational databases that can be queried via SQL are made for information storage and retrieval. That information can easily be culled for trends, statistics, correlations and etc. It's all a matter of developing the queries and reports.

What other solution? Possible using Splunk to gather information from the flat files, but that's not the same. That's not statistics in quite the same way.


Do not do it - it introduces another hugh system into something as simple as writing log files. Resetting the SQL Server interrupts the logging process.

What I Do is:

  • Logfiles onto a disc
  • Regular load scripts loading them into sql server. On an error, they just get reloaded after an hour with the next attempt ;)

Also see MS LogParser for loading IIS log FILES into SQL Server. e.g. http://www.jaygeiger.com/index.php/2010/11/09/load-iis-log-files-into-sql/