PHP output to a log file DEMO

We first need to ensure that the output files have permission to write, usually set permissions 

File output path chown -R nginx.nginx

If that does not work, the file can be directly provided with the 777, but this approach can only be used for testing environment

-R & lt the chmod 777 file path output

 

Way then to write the log file, the use of additional content that does not overwrite the previous log

$file = "notic_" . date("Ymd") . ".log";
$ct = date("Y-m-d H:i:s", time());
error_log("[" . $ct . "] 日志内容 \r\n", 3, $file);

 

Results are as follows:

 

Guess you like

Origin www.cnblogs.com/ryanzheng/p/11494960.html