Home  >  Article  >  php教程  >  PHP写日志的实现方法,php日志实现

PHP写日志的实现方法,php日志实现

WBOY
WBOYOriginal
2016-06-13 09:22:071334browse

PHP写日志的实现方法,php日志实现

本文实例讲述了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程序设计有所帮助。

php怎写日志

PHP 这东西做日志很让人揪心。。。
往数据库里面插吧,没别的什么好办法。。
数据量大可用先把数据按格式记录到文件里面,然后load数据库中。
 

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