使用php在日志文件中显示消息


show message in log file with php

我需要知道如何用php在apache的日志中显示消息,我知道java有这个指令

System.out.println

和在tcl

 ns_log notice

但是php中有一些等价的东西吗?

谢谢!!!

使用syslog函数:

http://php.net/manual/en/function.syslog.php

您可以使用error_log直接输出到错误日志。

使用error_log()函数设置自定义错误消息

error_log("Oracle database not available!", 0);

或者您可以将错误保存到自定义日志文件中作为

error_log("Oops, something went wrong!", 3, "/var/tmp/my-errors.log");

您必须设置PHP.ini上的日志记录级别,以进行调试或预热。然后使用error_log或syslog打印到php_error.log或您配置的日志文件是什么。