Home >Backend Development >PHP Tutorial >Recording site logs with SQL SERVER_PHP tutorial
Originally, just use W3C format
The problem is, sometimes, you may want to record the logs to another server, so that even if there is a problem, the logs will not be lost
Besides, use SQL for logging Another advantage is that it is convenient to access and query in the code, as well as statistical work
This statistics cannot be more accurate
Moreover, using SQL to record site logs is not complicated in itself
1. On the target server Create a database in SQL, for example, YAOANLOG
2, and run the log table generation script that comes with IIS in the database. This script is in the folder of the IIS server: c:windowssystem32inetsrv, and is named logtemp.sql. Run it and a data table named inetlog will be generated
3. On the IIS server, open the ODBC manager and create a system DSN. The DSN is called YAOANLOG. Select SQL SERVER as the driver and enter the IP of the SQL SERVER server. Address, verification, SQL SERVER verification, enter the user name and password, select the newly built YAOANLOG database as the database, and finally, test, if it passes, OK
4. Open the IIS manager, select the site to record the log, and select the log format , select ODBC mode
Next, click Properties
In the properties, DSN name, enter YaoAnLog
table name, enter inetlog
user name, enter your SQL SERVER user name, password, enter Password
Finally, press OK and you will be asked to enter the password again
After confirmation, stop the site and restart the site
If there is no problem with the settings, after connecting to the target SQL SERVER server, use query Analyzer, you should be able to see access log records
In addition, the IIS help mentioned: "If you use ODBC logs, IIS will disable the core cache and performance will be affected."
So , try not to use it unless necessary