When setting up an IIS website, PHP and MySQL are two commonly used elements, but you may encounter a 500 error during use. In this case, you need to check the logs to determine the problem. This article will introduce how to view the logs of IIS, PHP, and MySQL to facilitate error handling.
1. IIS log
2. PHP log
You can use the following function to open the error log in PHP:
ini_set('error_log', 'C:/path/to/php-error.log'); // 将错误日志打印到指定文件中 ini_set('log_errors', true); // 开启错误日志 error_reporting(-1); // 输出所有错误信息
It is recommended to print the error log to a separate file. for easy viewing. To view the error log, you can directly open it through the file path.
3. MySQL logs
MySQL logs are divided into error logs, warning logs, slow query logs and binary logs. They can be enabled through the following command line operations:
Add the following configuration to the MySQL configuration file to enable the error log:
log_error=/path/to/mysql-error.log
where/path/to/mysql-error.log
is the error log path.
Add the following configuration to the MySQL configuration file to enable the warning log:
log_warnings=2
where 2
is The level of warning.
Add the following configuration to the MySQL configuration file to enable the slow query log:
slow_query_log=1 slow_query_log_file=/path/to/mysql-slow.log
where/path/ to/mysql-slow.log
is the slow query log path.
Add the following configuration to the MySQL configuration file to enable binary log:
log-bin=/path/to/mysql-bin
where/path/to/ mysql-bin
is the binary log path.
Summary
This article introduces how to view the logs of IIS, PHP, and MySQL, which will be very helpful when troubleshooting errors. It should be noted that the log file may have a certain size, so the log file needs to be cleaned regularly to avoid insufficient disk space.
The above is the detailed content of How to view the logs of IIS, PHP, and MySQL. For more information, please follow other related articles on the PHP Chinese website!