柳暗花明笔记

    php一个相当好用的测试函数,我居然不知道 error_log

    所属分类:[ php&web ] 猫哲学家 发表于:2014-09-24 11:48 浏览:419

    可以向文件写错误日志,如:

    error_log(date('[Y-m-d H:i:s]') . 'test write log to file.' . PHP_EOL, 3, './php-log');

    error_log(date('[Y-m-d H:i:s]') . "\r\n" . print_r($cart, 1) . PHP_EOL, 3, DOCROOT . 'test-log');

    之前我都是用file_put_conents(), 来实现的,没想到php也有内置的函数,我们要尽量多用内置函数为好,痛哉..

     

    下面是php.ini的设置

    ; Besides displaying errors, PHP can also log errors to locations such as a
    ; server-specific log, STDERR, or a location specified by the error_log
    ; directive found below. While errors should not be displayed on productions
    ; servers they should still be monitored and logging is a great way to do that.
    ; Default Value: Off
    ; Development Value: On
    ; Production Value: On
    ; http://php.net/log-errors
    log_errors = On

     

    ; Set maximum length of log_errors. In error_log information about the source is
    ; added. The default is 1024 and 0 allows to not apply any maximum length at all.
    ; http://php.net/log-errors-max-len
    log_errors_max_len = 1024

    标签: php 
    上一编文章 php 判断移动设备访问 下一编文章 paypal ipn 接收到消息后并返回给paypal
    最近文章
    发表评论