Recently I was asked to set up ODBC Logging on a web server running Windows Server 2008 R2. The Website was programmed in ASP and some of the code was 32-bit so the Application Pool had 32-bit enabled.
This caused me a masive head ache as I just couldnt get ODBC logging to work it actually broke the aite when it was enabled. It turned out it was because the application pool was running in 32-bit but I had used a 64-bit DSN driver this broke the logging and hence the site. The answer was to set up the DSN using a 32-bit driver which is still included with Server 2008 R2.
Here is how to set up IIS logging on Windows Server 2008 R2 using a 32-bit driver:
What I did was to set the Custom logging was to create a Batch file to do it so I didn’t have o keep typing out the command.
cd "C:\Windows\System32\inetsrv"</em> appcmd.exe set config -section:ODBCLogging -dataSource:IISLog - tablename:inetlog -userName:iislog -password:pass1 appcmd.exe set sites "Your_Site" -LogFile.logformat:Custom -logfile.customLogPluginClsid:{FF16065B-DE82-11CF-BC0A-00AA006111E0}
The first line simply just changes the directory to where appcmd.exe is. The 2nd line then sets up the details for ODBC logging this sets the DataSource which is the DSN, the tablename, UserName and Password used to log into the database.
The 3rd line sets the Logging format for the site you specify. You must use the exact CLSID given aboth to set ODBC logging properly.
appcmd.exe basically just edits the IIS Application Host config file:
C:\Windows\\System32\Inetsrv\Config\ApplicationHost.config
So the best thing to do is to copy this file before you run any appcmd scripts or edit this file.
If you haven’t done already you need to create the DB on your SQL Server and then give the iislog user login rights to that DB. Then you must run an SQL script that comes with IIS this script is located in:
C:\Windows\system32\inetsrv\Logtemp.sql
This will create the table for you called inetlog. You can ofcours change the Table name just make sure you note all this details as you will need to change them using the above commands using appcmd.exe
Now you need to use the 32-bit SQL driver for this DSN to do this you must launch the 32-bit wizard. Click start run and type in this:
C:\Windows\SysWOW64\odbcad32.exe
Now create the DSN in the script at the top the DSN was called IISLog ofcourse you will have to edit this depending on what name you give your DSN.
If you have already tried ODBC logging and accidently used a 64-bit driver with a 32-bit pool then you must first remove all references you have added. Do this by opening up the IIS host configuration file located at:
C:\Windows\\System32\Inetsrv\Config\ApplicationHost.config
Backup this file first before editting it.
Once all references have been removed start again and it should work properly.
The post ODBC Logging with IIS7 and Windows 2008 R2 appeared first on Tom's Blog.