How do you handle system logs when using php to develop websites? I am using nginx server now. This can be used to prepare logs. In addition, log-related architecture is not used in the program. Like java, open-source tools similar to log4j are available. Does php need this? How do you handle system logs when using php to develop websites? I am using nginx server now. This can be used to prepare logs. In addition, log-related architecture is not used in the program. Like java, open-source tools similar to log4j are available. Does php need this?
Reply content:
How do you handle system logs when using php to develop websites? I am using nginx server now. This can be used to prepare logs. In addition, log-related architecture is not used in the program. Like java, open-source tools similar to log4j are available. Does php need this?
Nginx is the log of the application server. Generally, access logs are used most frequently to analyze the request URI, request consumption time, client information, and so on.
If a record is required in the business logic, it must be implemented in php. Php is relatively free. Generally, you can directly write string content to text log files. A better encapsulation can include these features: log classification, by date file, write buffer, complex structure escape, and so on.
You can refer to ZF Log implementation, you can also look at this project: https://github.com/katzgrau/KLogger
Simple business needs can be achieved by themselves, and some specifications can be referred to such as psr-3.
I also use php to monitor the log analysis Site status on the iis server. php reads and analyzes the logs two minutes ago and obtains useful information, such as 500 Error 404 error and access density... You can use it on your own, so it's a good time to troubleshoot the problem and track the trend.