I want to know if get IIS to log directly to the sql server is resource costive, and a better solution maybe generate log files, and each hour import this files to sql server.

Does it VERY big cost to log to sql server each request directly? The pages are open connection to the database anyway for each request.

link|improve this question

45% accept rate
feedback

1 Answer

Start here http://weblogs.asp.net/steveschofield/archive/2007/12/20/iis7-post-57-how-to-setup-odbc-logging-in-iis-7-0.aspx

Personally I haven't ever done this; rather I have setup a script to import old IIS logfiles into a SQL DB with Logparser.

Here is the PowerShell script I use

### Parameters ###
$iisLogLocation = "$env:systemdrive\inetpub\logs\logfiles"
$logParserLocation = "C:\Program Files\Log Parser 2.2"

### Main Script ###
$files = Get-ChildItem $iisLogLocation -Recurse |
    Where-Object{$_.LastWriteTime -le (Get-Date).Subtract((New-TimeSpan -Days 7))}

if ($files.Count -gt 0){
    foreach ($file in $files){
        $logParserArgs = @"
"SELECT LogFilename, LogRow, TO_LOCALTIME(TO_TIMESTAMP(date, time)), s-sitename, s-computername, s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs-version, cs(User-Agent), cs(Cookie), cs(Referer), cs-host, sc-status, sc-substatus, sc-win32-status, sc-bytes, cs-bytes, time-taken INTO IisLogData FROM $($file.FullName)" -o:SQL -server:.\sql01 -database:logs -ignoreIdCols:ON -fixColNames:ON -maxStrFieldLen:1000
"@
        Push-Location $logParserLocation
        LogParser.exe $logParserArgs
        Remove-Item $file.FullName
        Pop-Location
    }
}
link|improve this answer
how did you go? get odbc logging working? – commandbreak May 19 '10 at 23:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.