Home > Backend Development > PHP Tutorial > PHP如何输出调试信息到log里?

PHP如何输出调试信息到log里?

WBOY
Release: 2016-06-06 20:41:38
Original
2849 people have browsed it

PHP如何输出调试信息到log里,有什么好的方法吗?

回复内容:

PHP如何输出调试信息到log里,有什么好的方法吗?

你只需要

<code class="lang-php">error_log('你要输出的信息', 3, 'log文件路径');
</code>
Copy after login

即可

https://github.com/Seldaek/monolog

firePHP

error_log($msg);
trigger_error($msg);
这两个最简单,直接去php错误日志中找就行了

复杂点的file_put_contents($file_name, $msg, FILE_APPEND);

写入错误日志,或者exit 断点排错发

一般框架都有这种方法, 如果是自己开发的话封装个函数就好了.读写文件. 如果只是开发阶段的话完全没必要输出到log, 直接var_dump 到页面就好了啊.

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template