Home  >  Article  >  Backend Development  >  PHP写日志的实现方法_PHP

PHP写日志的实现方法_PHP

WBOY
WBOYOriginal
2016-05-31 19:28:15995browse

本文实例讲述了PHP写日志的实现方法。分享给大家供大家参考。具体实现方法如下:

代码如下:

function logError($content) 

  $logfile = '/logs/debuglog'.date('Ymd').'.txt'; 
  if(!file_exists(dirname($logfile))) 
  { 
    @File_Util::mkdirr(dirname($logfile)); 
  } 
  error_log(date("[Y-m-d H:i:s]")." -[".$_SERVER['REQUEST_URI']."] :".$content."\n", 3,$logfile); 
}


 
这里注意需要给记日志的目录权限:

代码如下:

chown -R  www:www csevent/


如果你的apache里配的不是www你要改为对应的
可以用ll命令查看你的权限

希望本文所述对大家的PHP程序设计有所帮助。

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