php 简单日志记录 log文件

Posted 黑白配

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 简单日志记录 log文件相关的知识,希望对你有一定的参考价值。

//日志记录
function writeFile($data,$type=‘a‘){
$filename = date("Ymd").".log";
$handle [email protected] fopen($filename, $type);
flock($handle, LOCK_EX);
ob_start();
echo "\n" . "[SQL]" . "\n";
print_r ($data);
$string = ob_get_contents();
ob_end_clean();
$fettle = @fwrite($handle, $string);
fclose($handle);
@chmod($filename,0777);
}

//接口用

 writeFile($sql);














以上是关于php 简单日志记录 log文件的主要内容,如果未能解决你的问题,请参考以下文章

thinkphp日志记录文件被存在了啥地方

Laravel 日志配置以及设置按日期记录日志

Laravel 记录日志

PHP 记录日志

学习笔记开源日志记录工具log4j使用方法

php实现日志管理(记录用户操作)原理