Home  >  Article  >  Backend Development  >  How to view the logs of IIS, PHP, and MySQL

How to view the logs of IIS, PHP, and MySQL

PHPz
PHPzOriginal
2023-03-29 15:13:441237browse

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

  1. Open IIS, find the website, right-click and select "Properties", and find the "Website Home Directory" tab.
  2. In the "Log File" column, select "Daily" or "Maximum File" as the log method.
  3. To view the log, you can view the path of the log file in "Website Properties" - "Log File".

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:

  1. Error log:

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.

  1. Warning log:

Add the following configuration to the MySQL configuration file to enable the warning log:

log_warnings=2

where 2 is The level of warning.

  1. Slow query log:

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.

  1. Binary log:

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn